Provider
The Provider component wraps part of an application to make TinyBase objects available throughout its component subtree via Svelte context.
Provider(props: ProviderProps): {
$on?: (type: string, callback: (e: any) => void): () => void;
$set?: (props: Partial<ProviderProps>): void;
}| Type | Description | |
|---|---|---|
props | ProviderProps | The props for this component. |
| returns | { $on?: (type: string, callback: (e: any) => void): () => void; $set?: (props: Partial<ProviderProps>): void; } | A rendering of the child components. |
Store objects, Metrics, Indexes, Relationships, Queries, Checkpoints, Persisters, and Synchronizers can all be provided both as single defaults and as named instances in a *ById map.
Provider components can be nested and their contexts are merged, so outer defaults and named instances remain visible unless a nearer Provider replaces them.
Example
This example creates a Provider context with a default Store.
// In a .svelte file:
// <Provider store={createStore()}>
// <App />
// </Provider>
Since
v8.1.0