Function WaitablesConsumer

A component that is rerendered based on input waitable and binding changes.

The general usage pattern is something like:

<WaitablesConsumer dependencies={{someWaitable, someBinding}} ifLoading={() => 'Loading…'}>
{({someWaitable, someBinding}) => <Typography>{someWaitable} - {someBinding}</Typography>}
<WaitablesConsumer>

Transformers may be passed as props or as children. The children may be a single transformer or an array, in which case the first applicable transformer is used. Transformers passed as children take precedence over those passed as props.

An unnamed transformer is the same as { ifLoaded: … }.

Named transformer meanings:

  • 'ifLoaded' - All of the waitables have defined values
  • 'ifError' - At least one waitable has a defined error
  • 'ifLoading' - At least one waitable has an undefined value but no waitables have defined errors
  • 'ifErrorOrLoading' - At least one waitable has an undefined value
  • 'always' - Always applicable

In addition to the specified transformers, a default ifError transformer is appended as the last fallback option, configurable using setDefaultWaitablesConsumerIfErrorTransformer, most useful for displaying error indicators when more precise handling isn't required.

If no transformers are applicable, nothing will be rendered.