Back to Trilium

Class default

docs/Script API/classes/Frontend_Script_API._internal_.default.html

0.102.26.5 KB
Original Source

Class default

Abstract class for all components in the Trilium's frontend.

Contains also event implementation with following properties:

  • event / command distribution is synchronous which among others mean that events are well-ordered - event which was sent out first will also be processed first by the component
  • execution of the event / command is asynchronous - each component executes the event on its own without regard for other components.
  • although the execution is async, we are collecting all the promises, and therefore it is possible to wait until the event / command is executed in all components - by simply awaiting the triggerEvent().

Hierarchy (View Summary)

Index

Constructors

constructor

Properties

_position$widgetchildrencomponentIdinitializedparent?

Accessors

positionsanitizedClassName

Methods

callMethodchildhandleEventhandleEventInChildrensetParenttriggerCommandtriggerEvent

Constructors

constructor

new default(): default

Returns default

Properties

_position

_position: number

$widget

$widget: JQuery<HTMLElement>

children

children: default[]

componentId

componentId: string

initialized

initialized: null | Promise<void>

Optionalparent

parent?: TypedComponent<any>

Accessors

position

get position(): number

Returns number

set position(newPosition: number): void

Parameters

  • newPosition: number

Returns void

sanitizedClassName

get sanitizedClassName(): string

Returns string

Methods

callMethod

callMethod(
fun: (arg: unknown) => Promise<unknown>,
data: unknown,
): undefined | Promise<unknown>

Parameters

  • fun: (arg: unknown) => Promise<unknown>
  • data: unknown

Returns undefined | Promise<unknown>

child

child(...components: default[]): default

Parameters

  • ...components: default[]

Returns default

handleEvent

handleEvent<T extends EventNames>(
name: T,
data: EventData<T>,
): undefined | null | Promise<unknown>

Type Parameters

Parameters

Returns undefined | null | Promise<unknown>

handleEventInChildren

handleEventInChildren<T extends EventNames>(
name: T,
data: EventData<T>,
): null | Promise<unknown>

Type Parameters

Parameters

Returns null | Promise<unknown>

setParent

setParent(parent: TypedComponent<any>): default

Parameters

Returns default

triggerCommand

triggerCommand<K extends keyof CommandMappings>(
name: K,
data?: CommandMappings[K],
): undefined | null | Promise<unknown>

Type Parameters

Parameters

Returns undefined | null | Promise<unknown>

triggerEvent

triggerEvent<T extends EventNames>(
name: T,
data: EventData<T>,
): undefined | null | Promise<unknown>

Type Parameters

Parameters

Returns undefined | null | Promise<unknown>

Settings

Member Visibility

  • Protected
  • Inherited
  • External

ThemeOSLightDark

On This Page

Constructors constructor Properties _position$widgetchildrencomponentIdinitializedparent Accessors positionsanitizedClassName Methods callMethodchildhandleEventhandleEventInChildrensetParenttriggerCommandtriggerEvent