For the complete documentation index, see llms.txt. This page is also available as Markdown.

Store

Simple store that can be hooked into React.

Source code is hosted on GitHub

yarn add @corets/store

Seamless React integration is shipped in a separate package:

useStore

There is a version of this package that syncs directly to the localStorage:

Local Storage Store

createStore()

Creates a new instance of observable store:

import { createStore } from "@corets/store"

const store = createStore({ some: "data" })

Create a new instance without the factory function:

import { Store } from "@corets/store"

const store = new Store({ some: "data" })

Create a new instance with a custom differ:

import { createStore } from "@corets/store"

const differ = (oldValue, newValue) => true
const store = createStore({ some: "data" }, { differ })

Store.get()

Retrieve everything from the store:

Store.set()

Replace everything in the store:

Store.put()

Update store by merging new and old state:

Store.listen()

Listen to changes:

Listen to changes with a custom differ:

Listen to a subset of data, using a custom mapper:

Store.use()

Convenience method for people used to React's useState syntax:

Last updated

Was this helpful?