Skip to content

Commit

Permalink
Lookup store by Object instead of name
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeroen van der Heijden committed Jun 7, 2018
1 parent 6273446 commit bf8f33c
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 15 deletions.
2 changes: 1 addition & 1 deletion dist/vlow.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import Component from './lib/component';
import {createActions} from './lib/actions';

const Vlow = {
version: '1.0.1',
version: '1.0.2',
};

Vlow.Store = Store;
Expand Down
9 changes: 5 additions & 4 deletions lib/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import States from './states';
import invariant from 'fbjs/lib/invariant';

let _stores = {};
let _stores = [];


class Store {
Expand Down Expand Up @@ -100,11 +100,12 @@ class Store {
}

static _vlowGetOrCreateStore(StoreClass) {
if (_stores[StoreClass.name] !== undefined) {
return _stores[StoreClass.name];
let storeMap = _stores.find((m) => m.class === StoreClass);
if (storeMap) {
return storeMap.store;
}
let store = new StoreClass();
_stores[StoreClass.name] = store;
_stores.push({class: StoreClass, store});
return store;
}
}
Expand Down
30 changes: 22 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vlow",
"version": "1.0.1",
"version": "1.0.2",
"description": "A simple library for unidirectional dataflow architecture inspired by Reflux",
"main": "dist/vlow.js",
"scripts": {
Expand Down

0 comments on commit bf8f33c

Please sign in to comment.