getStore
The getStore function returns the default Store from the current Provider context (or a named Store if an Id is provided).
getStore(id?: string): Store | undefinedExample
This example reads a TinyBase object from Svelte context inside a child component.
Child.svelte
<svelte:options runes={true} />
<script>
import {getStore} from 'tinybase/ui-svelte';
</script>
{getStore()?.getCell('pets', 'fido', 'species')}
App.svelte
<svelte:options runes={true} />
<script>
import {Provider} from 'tinybase/ui-svelte';
import Child from './Child.svelte';
let {store} = $props();
</script>
<Provider {store}>
<Child />
</Provider>
import {flushSync, mount} from 'svelte';
import {createStore} from 'tinybase';
import App from './App.svelte';
const store = createStore().setCell('pets', 'fido', 'species', 'dog');
const app = document.body.appendChild(document.createElement('div'));
flushSync(() => mount(App, {target: app, props: {store}}));
console.log(app.textContent);
// -> 'dog'
Since
v8.1.0