LinkedRowsView
LinkedRowsView(
this: void,
props: LinkedRowsViewProps,
): {
$on?: (type: string, callback: (e: any) => void): () => void;
$set?: (props: Partial<LinkedRowsViewProps>): void;
}| Type | Description | |
|---|---|---|
this | void | |
props | LinkedRowsViewProps | The props passed to the component. |
| returns | { $on?: (type: string, callback: (e: any) => void): () => void; $set?: (props: Partial<LinkedRowsViewProps>): void; } |
Example
This example creates TinyBase objects outside the component and renders the Svelte component with them.
App.svelte
<script>
import {LinkedRowsView} from 'tinybase/ui-svelte';
export let relationships;
</script>
{#snippet separator()}{' '}{/snippet}
<LinkedRowsView
relationshipId="nextPet"
firstRowId="fido"
{relationships}
{separator}
>
{#snippet row(rowId)}{rowId}{/snippet}
</LinkedRowsView>
import {flushSync, mount} from 'svelte';
import {createRelationships, createStore} from 'tinybase';
import App from './App.svelte';
const store = createStore()
.setTables({
pets: {
fido: {species: 'dog', color: 'brown', sold: false, next: 'felix'},
felix: {species: 'cat', color: 'black', sold: true},
},
species: {dog: {price: 5}, cat: {price: 4}},
})
.setValues({open: true, employees: 3});
const relationships = createRelationships(store).setRelationshipDefinition(
'nextPet',
'pets',
'pets',
'next',
);
const app = document.body.appendChild(document.createElement('div'));
flushSync(() => mount(App, {target: app, props: {relationships}}));
console.log(app.textContent);
// -> 'fido felix'
Since
v8.1.0