TinyBase logoTinyBase β

IndexView

IndexView(
  this: void,
  props: IndexViewProps,
): {
  $on?: (type: string, callback: (e: any) => void): () => void;
  $set?: (props: Partial<IndexViewProps>): void;
}
TypeDescription
thisvoid
propsIndexViewProps

The props passed to the component.

returns{ $on?: (type: string, callback: (e: any) => void): () => void; $set?: (props: Partial<IndexViewProps>): void; }

Example

This example creates TinyBase objects outside the component and renders the Svelte component with them.

App.svelte
<script>
  import {IndexView} from 'tinybase/ui-svelte';

  export let indexes;
</script>

{#snippet separator()}{' '}{/snippet}
<IndexView indexId="bySpecies" {indexes} {separator}>
  {#snippet slice(sliceId)}{sliceId}{/snippet}
</IndexView>
import {flushSync, mount} from 'svelte';
import {createIndexes, 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 indexes = createIndexes(store).setIndexDefinition(
  'bySpecies',
  'pets',
  'species',
);
const app = document.body.appendChild(document.createElement('div'));
flushSync(() => mount(App, {target: app, props: {indexes}}));
console.log(app.textContent);
// -> 'dog cat'

Since

v8.1.0