From 58cda9cc7fb79ca9df6746de7f9662bc08dc156a Mon Sep 17 00:00:00 2001 From: Stefan Malzner Date: Fri, 13 Oct 2017 12:29:40 +0200 Subject: initial commit --- src/stores/lib/Store.js | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 src/stores/lib/Store.js (limited to 'src/stores/lib/Store.js') diff --git a/src/stores/lib/Store.js b/src/stores/lib/Store.js new file mode 100644 index 000000000..873da7b37 --- /dev/null +++ b/src/stores/lib/Store.js @@ -0,0 +1,44 @@ +import { computed, observable } from 'mobx'; +import Reaction from './Reaction'; + +export default class Store { + stores = {}; + api = {}; + actions = {}; + + _reactions = []; + + // status implementation + @observable _status = null; + @computed get actionStatus() { + return this._status || []; + } + set actionStatus(status) { + this._status = status; + } + + constructor(stores, api, actions) { + this.stores = stores; + this.api = api; + this.actions = actions; + } + + registerReactions(reactions) { + reactions.forEach(reaction => this._reactions.push(new Reaction(reaction))); + } + + setup() {} + + initialize() { + this.setup(); + this._reactions.forEach(reaction => reaction.start()); + } + + teardown() { + this._reactions.forEach(reaction => reaction.stop()); + } + + resetStatus() { + this._status = null; + } +} -- cgit v1.2.3-70-g09d2