Core Concepts
We'll cover the following...
Sessions
The Session class is used to interact with an underlying set of data. If you use the reducer generated by createReducer(orm)
, Redux-ORM will create a Session instance internally. Otherwise, you can create Session instances by calling orm.session(entities)
(which creates a Session that will apply updates immutably), or orm.mutableSession(entities)
(which creates a Session that will directly mutate the provided data). Note that the “database tables” JS object you pass into orm.session()
doesn’t have to have come from the Redux store - you could easily use Redux-ORM outside of Redux, or pass in data that came from somewhere else.
A Session
instance has a reference to the current state object it’s wrapping as session.state
.
When a Session instance is created from source data, Redux-ORM creates temporary subclasses of the Model types available in the Schema, “binds” them to that session, and exposes the subclasses as fields on the Session instance. This means it’s important that you always extract the Model classes you want to use from the Session instance and interact with those, rather than using the versions you might have directly imported at the module level. If you’re writing your ...