Creating a Store
Last updated
Last updated
Creating a is the first thing you must do when getting started with Standard Resource.
The default export of the library is called createResourceStore
; it is a function that returns a store.
Because a store contains all of your , you only need a single store for your application.
Sometimes, you may want to instantiate a store with initial data. Typically, this feature is used when building progressive web apps, or universal apps.
In the above example, initialState
should be an entire state tree. If you have a store, you can access the state tree by calling .
createResourceStore
accepts a second argument, options
. This allows you to further configure the store.
Presently, there is only one option: schemas
. Use this option to configure the store with the for your resource types.
The store has helpful methods to create and update resources and groups. The following guides will cover how you can do those things.
There should only ever be one store in each application.