UNPKG

trc-client-core

Version:
54 lines (51 loc) 1.3 kB
var Reflux = require('reflux'); var ImmutableStoreMixin = require('reflux-immutable/ImmutableStoreMixin'); var LoadingActions = require('trc-client-core/src/global/LoadingActions'); var LoadingStore = Reflux.createStore({ listenables: LoadingActions, mixins: [ ImmutableStoreMixin ], init: function () { this.setState({ loading: false, type: null, message: null }); }, onStartLoading: function () { this.setState({ type: 'loading', loading: true }); }, onStopLoading: function () { this.setState({ type: null, loading: false }); }, onFlashMessage: function (type, message, length) { this.setState({ loading: true, type: type, message: message }); setTimeout(LoadingActions.clearAll, length || 1000); }, onShowMessage: function (type, message) { this.setState({ loading: true, type: type, message: message }); }, onClearAll: function () { this.setState({ message: null, type: null, loading: false }); } }); module.exports = LoadingStore;