mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-23 04:49:15 +08:00
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'.
59 lines
1.1 KiB
TypeScript
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]
|
|
}; |