Registry TypeAlias
A collection of entries looked up by a type string.
To use, import via fluid-framework/alpha.
For more information about our API support guarantees, see here.
This type is "input," meaning that code outside of the library defining it should not read from it. Future versions of this type may add optional members or make typing of members more general.
Signature
export type Registry<T> = (type: string) => T;
Type Parameters
| Parameter | Description |
|---|---|
| T | The type of entry produced for any given type string. |
Remarks
Use of a function for this allows a few things that most collections would not: 1. It's possible to generate placeholder / error values on demand. 2. It makes loading from some external registry on demand practical. 3. The lookup can throw an exception if appropriate (this would typically indicate a bug and produce a fatal error). 4. Generation of values can be lazy, and even asynchronous if T allows for a promise.
This flexibility lets the implementer decide how to handle requests for unknown types. They can produce placeholders, assert, fall back to a generic implementation etc.