Defer
Description
The Defer component allows you to render content asynchronously. The asynchronous task is triggered only on the first render of the Defer component. This is useful for loading heavy components or data without blocking the initial UI rendering. You can also provide a load message or skeleton to display while the content is loading.
Usage
Use the Defer helper method from Tesserae.UI. It accepts an asynchronous function that returns the component to be rendered.
API reference
internal sealed class DeferedComponent : IDeferA placeholder that asynchronously loads its real content from a Task, optionally showing a loading state while waiting.
Methods
public IDefer Debounce(int delayInMs, int millisecondsForLoadingMessage = 1000)The milliseconds must be a value of at least one, trying to disable Debounce by passing a zero (or negative) value is not supported
public IDefer Debounce(int delayInMs, int maxDelayInMs, int millisecondsForLoadingMessage = 1000)Configures the component to debounce.
public IDefer DoNotWaitForComponentMountingBeforeRendering()By default, the component will generate an empty container and only start to initiate the data retrieval and full rendering process when it is mounted in the DOM (so that things like height calculations may be performed accurately, which require that the component exist in its expected location in the DOM) but this can be expensive if rendering many items. If it is known that the component is immediately going to be mounted then this method may be called and the DomObserver.WhenMounted logic will be bypassed and replaced with a simple setTimeout of very short duration (to allow the immediate rendering of the element to take place).
Samples
Basic Defer Usage
This sample demonstrates how to use Defer to load content after a delay.