Core render middleware

    The most important middleware which provides a hook into a widget’s invalidation lifecycle. Calling invalidator() will queue the widget for rendering during the next scheduled render.

    API:

    • invalidator()

    node

    Provides widgets access to their underlying DOM nodes, identified by node keys. When a valid DOM node is requested but unavailable, Dojo will re-render the widget as soon as the DOM node becomes available.

    API:

    • node.get(key: string | number): HTMLElement | null
      • Returns the widget’s specified DOM element, identified by the node’s key property. Returns null if the specified DOM element does not exist for the current widget.

    Writing custom diff functions is typically coupled with use of the middleware to flag the current widget as invalid when a difference in property values requires the widget’s DOM nodes to be updated.

    Note: Only a single diff function can be registered for a given property during the lifetime of a composing widget or middleware, after which subsequent calls will be ignored. By default the rendering engine uses an algorithm that shallowly diffs objects and arrays, ignores functions, and equality checks all other property types. Setting a custom diff function overrides Dojo’s default difference detection strategy for the property.

    API:

    • diffProperty(propertyName: string, diff: (current: any, next: any) => void)
      • Registers the specified diff function that is called to determine if any differences exist between the current and next values of the widget’s propertyName property.

    destroy

    Assigns a function that is called on widget destruction, allowing any required resource teardown to take place.

    API:

    1. import destroy from '@dojo/framework/core/vdom';
    • destroy(destroyFunction: () => void)

    Provides access to the widget’s own Registry instance, as well as the root application Registry if required, via a handler interface.

    Note: The registry is an advanced concept not typically required when writing Dojo applications. It is mainly used internally by the framework to implement more advanced user-facing functionality such as .

    API:

    • getRegistry(): RegistryHandler | null
      • Returns the RegistryHandler for the current widget, or null if the widget has not yet been fully initialized.

    defer

    API:

    1. import defer from '@dojo/framework/core/vdom';
      • Pauses further rendering of the current widget until flagged otherwise.
    • defer.resume()
      • Resumes widget rendering.