@searchspring/snap-store-mobx
v0.63.0
Published
Snap MobX Store
Downloads
2,404
Readme
Snap MobX Store
Management of Snap state using Mobx.
Dependency
Snap Store MobX is a dependency of @searchspring/snap-controller
Dependencies
Snap Store MobX requires the following dependencies as services:
@searchspring/snap-url-manager
Installation
npm install --save @searchspring/snap-store-mobx
Import
import { AbstractStore, SearchStore, AutocompleteStore, FinderStore, RecommendationStore, StorageStore } from '@searchspring/snap-store-mobx';
Controller usage
Snap Store MobX is a dependency of Snap Controller which will handle store changes as needed. As such, it is recommended to use methods of the controller to access and update the store.
Standalone usage
import { SearchStore } from '@searchspring/snap-store-mobx'
import { UrlManager, UrlTranslator } from '@searchspring/snap-url-manager';
const searchConfig = {
id: 'search',
globals: {
pagination: {
pageSize: 12
}
}
};
const store = new SearchStore(searchConfig, { urlManager: new UrlManager(new UrlTranslator()) });
store.update(data);
// log the store
console.log(store.toJSON());