State management framework
npm install @flexbase/store

```
npm install @flexbase/store
or
``
yarn add @flexbase/store
The concept behind the store is to separate state management from other application concerns. It is Promise based utilizing an Observer pattern.
Example data
`ts`
interface SomeData {
name: string;
id: number;
}
`ts
const someDataStore = createStore
const someOtherStore = createStore
`
#### Create Store Options
`ts
// object style
const someDataStore = createStore
key?: symbol, // use the specified key to represent this store; otherwise Symbol() is used
defaultValue?:
comparer?: StoreComparer
middleware?: StoreMiddleware
persistanceProvider?: PersistanceProvider
storageManager: StorageManager // use the specified storage manager; otherwise use the global manager
});
// fluent style
const someDataStore = createStore
options
.key(key: symbol | string) // use the specified key to represent this store; otherwise Symbol() is used
.defaultValue(value:
.comparer(comparer: StoreComparer
.middleware(...middleware: StoreMiddleware
.persistanceProvider(persistanceProvider: PersistanceProvider
.storageManager(storageManager: StorageManager) // use the specified storage manager; otherwise use the global manager
});
`
`ts`
const value = getStoreValue(someDataStore);
`ts
await setStoreValue(someDataStore, { name: 'Test', id: 1 });
await setStoreValue(someOtherStore, 42);
`
#### Using a callback
`ts
await setStoreValue(someDataStore, _ => {name: 'Test', id: 1});
await setStoreValue(someOtherStore, _ => 42);
// do more in the callback
await setStoreValue(test, currentValue => (currentValue ? Math.min(42, currentValue) : 0));
`
`ts
let value: number;
const numberStore = createStore
value = storageManager.getValue(numberStore); // value is 42
await storageManager.setValue(numberStore, 1);
value = storageManager.getValue(numberStore); // value is 1
await resetStoreValue(numberStore);
value = storageManager.getValue(numberStore); // value is 42
`
`ts
const setter = getStoreSetter(someDataStore);
await setter({ name: 'Test', id: 1 });
await setter(_ => {name: 'Test', id: 1});
`
`ts
const subscription = subscribeToStore(someDataStore, context => {...});
subscription.unsubscribe();
``
TODO
TODO