Files
DefinitelyTyped/reflux/reflux-tests.ts
Andy Hanson 9608cfb4ef Fix packages that used 'jasmine' for tests.
Jasmine requires TypeScript 2.1, but since these packages only use it for tests, they should stop depending on it and stay TS2.0 compatible.
Similar for 'react'.
2017-02-23 08:47:29 -08:00

59 lines
1.1 KiB
TypeScript

import Reflux = require("reflux");
var syncActions = Reflux.createActions([
"statusUpdate",
"statusEdited",
"statusAdded"
]);
var asyncActions = Reflux.createActions({
fireBall: {asyncResult: true}
});
asyncActions.fireBall.listen(function() {
// Trigger async action
setTimeout(() => this.completed(true), 1000);
});
// Creates a DataStore
var statusStore = Reflux.createStore({
// Initial setup
init() {
// Register statusUpdate action
this.listenTo(asyncActions.fireBall, this.onFireBall);
},
// Callback
onFireBall(flag: boolean) {
var status = flag ? 'ONLINE' : 'OFFLINE';
// Pass on to listeners
this.trigger(status);
}
});
Reflux.createAction({
children: ["progressed", "completed", "failed"]
});
var action = Reflux.createAction();
var actions = Reflux.createActions(["fireBall", "magicMissile"]);
var Store = Reflux.createStore({
init() {
this.listenToMany(actions);
},
onFireBall() {
// whoooosh!
},
onMagicMissile() {
// bzzzzapp!
}
});
var ReactComponent = {
mixins: [Reflux.ListenerMixin]
};