TinyBase logoTinyBase

setValuesSchema

The setValuesSchema method lets you specify the ValuesSchema of the keyed Values part of the Store.

setValuesSchema(valuesSchema: ValuesSchema): Store
TypeDescription
valuesSchemaValuesSchema

The ValuesSchema to be set for the Store.

returnsStore

A reference to the Store.

Note that this may result in a change to data in the Store, as defaults are applied or as invalid Values are removed. These changes will fire any listeners to that data, as expected.

When no longer needed, you can also completely remove an existing ValuesSchema with the delValuesSchema method.

Example

This example sets the ValuesSchema of a Store after it has been created.

const store = createStore().setValuesSchema({
  open: {type: 'boolean', default: false},
});
store.setValue('open', 'maybe');

console.log(store.getValues());
// -> {open: false}

Since

v3.0.0