Creating a Store
Creating a store 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 resource data, you only need a single store for your application.
Initial State
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 store.getState()
.
Passing options
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 schemas for your resource types.
Using the store
The store has helpful methods to create and update resources and groups. The following guides will cover how you can do those things.
Tips
There should only ever be one store in each application.
Last updated