@searchspring/snap-store-mobx

Snap MobX Store

Usage no npm install needed!

<script type="module">
  import searchspringSnapStoreMobx from 'https://cdn.skypack.dev/@searchspring/snap-store-mobx';
</script>

README

Snap MobX Store

NPM Status

Management of Snap state using Mobx.

Dependency

Snap Store MobX is a dependency of @searchspring/snap-controller NPM Status

Dependencies

Snap Store MobX requires the following dependencies as services:

NPM Status @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());