Skip to content

almin/legacy-store-group

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@almin/legacy-store-group Build Status

Almin old StoreGroup and QueuedStoreGroup implementation.

  • StoreGroup: Almin <0.12 StoreGroup implementation.
  • QueuedStoreGroup: Almin <0.12 include this implementation.

📝 Migration

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

Install with npm:

npm install @almin/legacy-store-group

Usage

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

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

  • 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
Checking Algorithm

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
Note
  • 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.

Changelog

See Releases page.

Running tests

Install devDependencies and Run npm test:

npm i -d && npm test

Contributing

Pull requests and stars are always welcome.

For bugs and feature requests, please create an issue.

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

Author

License

MIT © azu

About

Almin old StoreGroup and QueuedStoreGroup implementation.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published