Helpers
parentStore(Store)
Marks store definition as parent-scoped.
ts
import { parentStore } from '@lomray/react-mobx-manager';
const stores = {
someOtherStore: parentStore(SomeOtherStore),
};Returned runtime value:
ts
{
store: SomeOtherStore,
isParent: true
}Manager.persistStore(Store, id?, options?)
Marks store as persisted and wires default persistence hooks.
ts
export default Manager.persistStore(UserStore, 'user');makeFetching(instance, params, hasLock?)
Wraps store methods and toggles boolean fetching flags around sync or async execution.
ts
makeFetching(this, {
getNameFromApi: 'isLoading',
});Each method maps to one flag — or to several flags via a readonly tuple. All flags in the tuple flip in a single runInAction, so observers see them change atomically:
ts
makeFetching(this, {
verify: ['isVerifying', 'hasStartedBrowserFromModal'] as const,
});When hasLock is true, the method call is dropped only while every mapped flag is already true, so a partially-set state still lets the call through.
makeExported(store, params)
Controls what parts of the store become exportable or serializable.
ts
makeExported(this, {
someField: 'simple',
});Use it when you want explicit control over what Manager.toJSON() or persistence-related export logic should include.
Markers:
'simple'includes a plain field as-is'observable'exports nested observable data recursively'excluded'explicitly removes a field from export
This is especially useful when:
- a store uses
isNotExported: trueinpersistStore(...) - only a subset of fields should be serialized
- you need to export non-observable metadata together with observable state