Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface ILifecycle

Hierarchy

  • ILifecycle

Index

Methods

Optional init

  • init(el: Element, ctx: any, ...args: any[]): void
  • Component init method. Called with the actual DOM element, hdom user context and any other args when the component is first used, but after render() has been called once already AND all of the components children have been realized. Therefore, if any children have their own init lifecycle method, these hooks will be executed before that of the parent.

    Parameters

    • el: Element
    • ctx: any
    • Rest ...args: any[]

    Returns void

Optional release

  • release(ctx: any, ...args: any[]): void
  • Called when the underlying DOM of this component is removed (or replaced). Intended for cleanup tasks.

    Parameters

    • ctx: any
    • Rest ...args: any[]

    Returns void

render

  • render(ctx: any, ...args: any[]): any
  • Returns the hdom tree of this component. Note: Always will be called first (prior to init/release) to obtain the actual component definition used for diffing. Therefore might have to include checks if any local state has already been initialized via init. This is the only mandatory method which MUST be implemented.

    render is executed before init because normalizeTree() must obtain the component's hdom tree first before it can determine if an init is necessary. init itself will be called from diffTree, createDOM or hydrateDOM() in a later phase of processing.

    render should ALWAYS return an array or another function, else the component's init or release fns will NOT be able to be called later. E.g. If the return value of render evaluates as a string or number, the return value should be wrapped as ["span", "foo"]. If no init or release are used, this requirement is relaxed.

    Parameters

    • ctx: any
    • Rest ...args: any[]

    Returns any

Generated using TypeDoc