mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
47 lines
895 B
TypeScript
47 lines
895 B
TypeScript
import { createDispatcher, Store } from 'dispatchr';
|
|
import createStore = require('dispatchr/addons/createStore');
|
|
import BaseStore = require('dispatchr/addons/BaseStore');
|
|
|
|
const TestStore = createStore({
|
|
storeName: 'TestStore',
|
|
|
|
handlers: {
|
|
ACTION_NAME: 'actionHandler'
|
|
},
|
|
|
|
statics: {
|
|
staticMethod() {}
|
|
},
|
|
|
|
initialize() { },
|
|
|
|
actionHandler() {
|
|
this.emitChange();
|
|
this.additionalMethod();
|
|
},
|
|
|
|
additionalMethod() {}
|
|
});
|
|
|
|
class ExtendedStore extends BaseStore {
|
|
static handlers = {
|
|
ACTION_NAME: 'actionHandler'
|
|
};
|
|
|
|
actionHandler() {
|
|
this.emitChange();
|
|
}
|
|
}
|
|
|
|
const dispatcher = createDispatcher({
|
|
errorHandler(e, context) {
|
|
e.meta;
|
|
e.type;
|
|
e.message;
|
|
},
|
|
stores: [TestStore]
|
|
});
|
|
|
|
const context = dispatcher.createContext({});
|
|
context.dispatch('ACTION_NAME', {});
|