Task backed components
Using task backed components
task
.Name | Description |
---|---|
task | string
| {
slug: string;
params?: Record<string, any>;
refetchInterval?: number;
onSuccess?: (output?: TOutput) => void;
onFailure?: (output?: TOutput, error?: TError) => void;
executeOnMount?: boolean;
executeOnWindowFocus?: boolean;
executeOnReconnect?: boolean;
}
| AirplaneFunc
| {
fn: AirplaneFunc;
params?: Record<string, any>;
refetchInterval?: number;
onSuccess?: (output?: TOutput) => void;
onFailure?: (output?: TOutput, error?: TError) => void;
executeOnMount?: boolean;
executeOnWindowFocus?: {boolean;
executeOnReconnect?: boolean;
} The task query to execute when this component loads. The component's data will be populated by the task's output and loading and error states will be handled automatically. If the task doesn't require any parameters or special options, you can just pass the task slug ( If the task requires parameters, these can be passed in via The The The |
By task function
AirplaneFunc
which is the value
returned by the airplane.task
function. This is only feasible if your task is in the file as your
view or is in the same project and is imported.refetchInterval
that refetches the task every 10s.By slug
slug
of an Airplane task to the component.refetchInterval
that refetches the task every 10s.Transforming data
outputTransform
prop that allows you to transform the
data before it is displayed by the component.Which components can be task backed?
task
prop:Form
Form
can also be task backed, but a task-backed form automatically infers its
fields from the task parameters, and the parameter values can be set using the form values. The
task
prop on Form
follows a modified API that allows the inputs for each parameter to be
customized.Name | Description |
---|---|
task | string
| {
slug: string;
shownFields?: string[];
hiddenFields?: string[];
fieldOptions?: {
slug: string;
value?: string | number | boolean | Date;
allowedValues?: string[] | number[] | Date;
}[];
} The task associated with the form. This can either be a string, corresponding to the task slug, or an options struct, for which the task slug must be passed in the slug field. If shownFields is set, only fields in shownFields are shown. If hiddenFields is set, fields in hiddenFields are hidden.fieldOptions can be used to restrict the values for a field. Each option in fieldOptions has a slug field, corresponding to the parameter slug. |