Almin old StoreGroup and QueuedStoreGroup implementation.
StoreGroup
: Almin <0.12StoreGroup
implementation.QueuedStoreGroup
: Almin <0.12 include this implementation.
These StoreGroups has been deprecated.
Almin ^0.12 has new StoreGroup
that change the arguments of constructor.
You can migrate the old StoreGroup
to the new StoreGroup
.
Install with npm:
npm install @almin/legacy-store-group
They have same interface.
import { Store } from "almin";
import { StoreGroup, QueuedStoreGroup } from "@almin/legacy-store-group";
class AStore extends Store {
constructor() {
super();
this.state = {};
}
getState() {
return {
"aState": this.state
};
}
}
const aStore = new AStore();
const storeGroup = new StoreGroup([aStore]);
storeGroup.onChange((changedStores) => {
const state = storeGroup.getState();
/*
{
"aState": ...
}
*/
});
StoreGroup is a collection of Store.
- Throttling change events of Store for UI updating.
- A central manager of stores.
StoreGroup has event queue system.
It means that StoreGroup thin out change events of stores.
If you want to know all change events, and directly use store.onChange()
.
- QueuedStoreGroup is a UI parts of Store.
- QueuedStoreGroup has event queue system.
- QueuedStoreGroup not dependent on async function like
setTimeout
. - QueuedStoreGroup work as Sync or Async.
- QueuedStoreGroup prefer strict design than ./StoreGroup.js
QueuedStoreGroup check changed stores and QueuedStoreGroup#emitChange()
(if necessary) on following case:
- when receive
didExecutedUseCase
events - when receive events by
UseCase#dispatch
- when receive events by
UseCase#throwError
- QueuedStoreGroup not allow to change stores directly.
- Always change stores via execution of UseCase.
- QueuedStoreGroup has not cache state.
- Cache system should be in your Store.
See Releases page.
Install devDependencies and Run npm test
:
npm i -d && npm test
Pull requests and stars are always welcome.
For bugs and feature requests, please create an issue.
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request :D
MIT © azu