FormulaFunction
Unofficial
A Bases formula function, such as now() or the contains() of a string.
A plugin adds its own with obsidian#Plugin.registerGlobalFunc or obsidian#Plugin.registerInstanceFunc. The built-in functions derive from a base class that is not exported, so a plugin implements every member, including FormulaFunction.applyWithContext, which is the one the evaluator calls.
Import:
import type { FormulaFunction } from '@obsidian-typings/obsidian-catalyst-latest';Signature:
export interface FormulaFunctionProperties
| Property | Type | Description | |
|---|---|---|---|
| ctx | FormulaContext | null | The context of the evaluation in progress, set by FormulaFunction.applyWithContext and null outside it. | |
| docString? | (() => string) | string | The description shown in the formula autocomplete, or a function returning it. | |
| name | string | The name of the function. It is matched case-insensitively, and registering a name again replaces the previous function. | |
| params | FormulaFunctionParam[] | The parameters of the function. For an instance function, the first parameter is the value the function is called on. |
Methods
| Method | Returns | Description | |
|---|---|---|---|
| apply(args?) | Value | Evaluates the function. | |
| applyWithContext(ctx, args?) | Value | Evaluates the function in a formula context: sets FormulaFunction.ctx, calls FormulaFunction.apply, then resets it. | |
| serialize(args?) | string | Serializes a call to the function back to formula source. |
Links to this page: