Composables
Store's composables.
useCell
The useCell
composable returns a readonly reference to an object containing the value of a single Cell in a given Row, in a given Table, and registers a listener so that any changes to that result will cause a re-render.
When first accessed, this composable will create a listener so that changes to the Cell will cause a re-render. When the component containing this composable is unmounted, the listener will be automatically removed.
NOTE
There's a writable alternative to this composable called cellRef
Parameters
tableId
(MaybeRefOrGetter
<string>
): The Id of the Table in the Store.rowId
(MaybeRefOrGetter
<string>
): The Id of the Row in the Table.cellId
(MaybeRefOrGetter
<string>
): The Id of the Cell in the Row.
Returns
ComputedRef<
CellOrUndefined
>
: A readonly reference to the value of the Cell.
Example
useCellIds
The useCellIds
composable returns a readonly reference to the Ids of every Cell in a given Row, in a given Table, and registers a listener so that any changes to that result will cause a re-render.
When first accessed, this composable will create a listener so that changes to the Cell Ids will cause a re-render. When the component containing this composable is unmounted, the listener will be automatically removed.
Parameters
tableId
(MaybeRefOrGetter
<string>
): The Id of the Table in the Store.rowId
(MaybeRefOrGetter
<string>
): The Id of the Row in the Table.
Returns
Example
useHasCell
The useHasCell
composable returns a readonly reference to a boolean indicating whether a given Cell exists in a given Row in a given Table, and registers a listener so that any changes to that result will cause a re-render.
When first accessed, this composable will create a listener so that changes to the Cell will cause a re-render. When the component containing this composable is unmounted, the listener will be automatically removed.
Parameters
tableId
(MaybeRefOrGetter
<string>
): The Id of the Table in the Store.rowId
(MaybeRefOrGetter
<string>
): The Id of the Row in the Table.cellId
(MaybeRefOrGetter
<string>
): The Id of the Cell in the Row.
Returns
ComputedRef<boolean>
: A readonly reference to a boolean indicating whether a Cell with that Id exists in that Row in that Table.
Example
useHasRow
The useHasRow
composable returns a readonly reference to a boolean indicating whether a given Row exists in the Store, and registers a listener so that any changes to that result will cause a re-render.
When first accessed, this composable will create a listener so that changes to the Row will cause a re-render. When the component containing this composable is unmounted, the listener will be automatically removed.
Parameters
tableId
(MaybeRefOrGetter
<string>
): The Id of the Table in the Store.rowId
(MaybeRefOrGetter
<string>
): The Id of the Row in the Table.
Returns
Example
useHasTable
The useHasTable
composable returns a readonly reference to a boolean indicating whether a given Table exists in the Store, and registers a listener so that any changes to that result will cause a re-render.
When first accessed, this composable will create a listener so that changes to the Table will cause a re-render. When the component containing this composable is unmounted, the listener will be automatically removed.
Parameters
tableId
(MaybeRefOrGetter
<string>
): The Id of the Table in the Store.
Returns
ComputedRef<boolean>
: A readonly reference to a boolean indicating whether the Table exists.
Example
useHasTableCell
The useHasTableCell
composable returns a readonly reference to a boolean indicating whether a given Cell exists anywhere in a Table, not just in a specific Row, and registers a listener so that any changes to that result will cause a re-render.
When first accessed, this composable will create a listener so that changes to the Table will cause a re-render. When the component containing this composable is unmounted, the listener will be automatically removed.
Parameters
tableId
(MaybeRefOrGetter
<string>
): The Id of the Table in the Store.cellId
(MaybeRefOrGetter
<string>
): The Id of the Cell in the Table.
Returns
ComputedRef<boolean>
: A readonly reference to a boolean indicating whether the Cell exists in the Table.
Example
useHasTables
The useHasTables
composable returns a readonly reference to a boolean indicating whether any Table objects exist in the Store, and registers a listener so that any changes to that result will cause a re-render.
When first accessed, this composable will create a listener so that changes to the Tables will cause a re-render. When the component containing this composable is unmounted, the listener will be automatically removed.
Returns
ComputedRef<boolean>
: A readonly reference to a boolean indicating whether any Tables exist.
Example
useHasValue
The useHasValue
composable returns a readonly reference to a boolean indicating whether a given Value exists in the Store, and registers a listener so that any changes to that result will cause a re-render.
When first accessed, this composable will create a listener so that changes to the Value will cause a re-render. When the component containing this composable is unmounted, the listener will be automatically removed.
Parameters
valueId
(MaybeRefOrGetter
<string>
): The Id of the Value in the Store.
Returns
ComputedRef<boolean>
: A readonly reference to a boolean indicating whether a Value with that Id exists in the Store.
Example
useHasValues
The useHasValues
composable returns a readonly reference to a boolean indicating whether any Values exist in the Store, and registers a listener so that any changes to that result will cause a re-render.
When first accessed, this composable will create a listener so that changes to the Values will cause a re-render. When the component containing this composable is unmounted, the listener will be automatically removed.
Returns
ComputedRef<boolean>
: A readonly reference to a boolean indicating whether any Values exist in the Store.
Example
useRow
The useRow
composable returns a readonly reference to the object containing the data of a single Row in a given Table, and registers a listener so that any changes to that result will cause a re-render.
When first accessed, this composable will create a listener so that changes to the Row will cause a re-render. When the component containing this composable is unmounted, the listener will be automatically removed.
NOTE
There's a writable alternative to this composable called rowRef
Parameters
tableId
(MaybeRefOrGetter
<string>
): The Id of the Table in the Store.rowId
(MaybeRefOrGetter
<string>
): The Id of the Row in the Table.
Returns
Example
useRowCount
The useRowCount
composable returns a readonly reference to the count of the Row objects in a given Table, and registers a listener so that any changes to that result will cause a re-render.
When first accessed, this composable will create a listener so that changes to the count of Row objects will cause a re-render. When the component containing this composable is unmounted, the listener will be automatically removed.
Parameters
tableId
(MaybeRefOrGetter
<string>
): The Id of the Table in the Store.
Returns
Example
useRowIds
The useRowIds
composable returns a readonly reference to the Ids of every Row in a given Table, and registers a listener so that any changes to that result will cause a re-render.
When first accessed, this composable will create a listener so that changes to the Row Ids will cause a re-render. When the component containing this composable is unmounted, the listener will be automatically removed.
Parameters
tableId
(MaybeRefOrGetter
<string>
): The Id of the Table in the Store.
Returns
Example
useSortedRowIds
The useSortedRowIds
composable returns a readonly reference to the sorted (and optionally, paginated) Ids of every Row in a given Table, and registers a listener so that any changes to that result will cause a re-render.
When first accessed, this composable will create a listener so that changes to the sorted Row Ids will cause a re-render. When the component containing this composable is unmounted, the listener will be automatically removed.
Parameters
tableId
(MaybeRefOrGetter
<string>
): The Id of the Table in the Store.cellId
? (MaybeRefOrGetter
<string | undefined>
): The Id of the Cell whose values are used for the sorting, orundefined
to by sort the Row Id itself.descending
? (MaybeRefOrGetter
<boolean | undefined>
): Whether the sorting should be in descending order.offset
? (MaybeRefOrGetter
<number | undefined>
): The number of Row Ids to skip for pagination purposes, if any.limit
? (MaybeRefOrGetter
<number | undefined>
): The maximum number of Row Ids to return, or undefined for all.
Returns
ComputedRef<
Ids
>
: A readonly reference to an array of the sorted Ids of every Row in the Table.
Example
// store
export const store = createStore().setTables({
pets: {
fido: { species: 'dog' },
felix: { species: 'cat' },
},
})
useTable
The useTable
composable returns a readonly reference to an object containing the data of a single Table in a Store, and registers a listener so that any changes to that result will cause a re-render.
When first accessed, this composable will create a listener so that changes to the Table will cause a re-render. When the component containing this composable is unmounted, the listener will be automatically removed.
NOTE
There's a writable alternative to this composable called tableRef
Parameters
tableId
(MaybeRefOrGetter
<string>
): The Id of the Table in the Store.
Returns
Example
useTableCellIds
The useTableCellIds
composable returns a readonly reference to the Ids of every Cell used across the whole Table, and registers a listener so that any changes to that result will cause a re-render.
When first accessed, this composable will create a listener so that changes to the Table Cell Ids will cause a re-render. When the component containing this composable is unmounted, the listener will be automatically removed.
Parameters
tableId
(MaybeRefOrGetter
<string>
): The Id of the Table in the Store.
Returns
ComputedRef<
Ids
>
: A readonly reference to an array of the Ids of every Cell used across the whole Table.
Example
useTableIds
The useTableIds
composable returns a readonly reference to the Ids of every Table in a Store, and registers a listener so that any changes to that result will cause a re-render.
When first accessed, this composable will create a listener so that changes to the Table Ids will cause a re-render. When the component containing this composable is unmounted, the listener will be automatically removed.
Returns
Example
useTables
The useTables
composable returns a readonly reference to a Tables object containing the tabular data of a Store, and registers a listener so that any changes to that result will cause a re-render.
When first accessed, this composable will create a listener so that changes to the Tables will cause a re-render. When the component containing this composable is unmounted, the listener will be automatically removed.
NOTE
There's a writable alternative to this composable called tablesRef
Parameters
Returns
ComputedRef<
Tables
>
: A readonly reference to the Tables object containing the tabular data of the Store.
Example
useValue
The useValue
composable returns a readonly reference to an object containing the data of a single Value in a Store, and registers a listener so that any changes to that result will cause a re-render.
When first accessed, this composable will create a listener so that changes to the Value will cause a re-render. When the component containing this composable is unmounted, the listener will be automatically removed.
NOTE
There's a writable alternative to this composable called valueRef
Parameters
valueId
(MaybeRefOrGetter
<string>
): The Id of the Value in a Store.
Returns
Example
useValueIds
The useValueIds
composable returns a readonly reference to the Ids of every Value in a Store, and registers a listener so that any changes to that result will cause a re-render.
When first accessed, this composable will create a listener so that changes to the Value Ids will cause a re-render. When the component containing this composable is unmounted, the listener will be automatically removed.
Parameters
Returns
Example
useValues
The useValues
composable returns a readonly reference to a Values object containing the keyed value data of a Store, and registers a listener so that any changes to that result will cause a re-render.
When first accessed, this composable will create a listener so that changes to the Values will cause a re-render. When the component containing this composable is unmounted, the listener will be automatically removed.
NOTE
There's a writable alternative to this composable called valuesRef
Returns
ComputedRef<
Values
>
: A readonly reference to a Values object containing the keyed value data of the Store.