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 key
s. 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. Returnsnull
if the specified DOM element does not exist for the current widget.
- Returns the widget’s specified DOM element, identified by the node’s
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 thecurrent
andnext
values of the widget’spropertyName
property.
- Registers the specified
destroy
Assigns a function that is called on widget destruction, allowing any required resource teardown to take place.
API:
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, ornull
if the widget has not yet been fully initialized.
- Returns the
defer
API:
import defer from '@dojo/framework/core/vdom';
- Pauses further rendering of the current widget until flagged otherwise.
defer.resume()
- Resumes widget rendering.