mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
# Conflicts: # angular-ui-router/angular-ui-router.d.ts # bookshelf/bookshelf-tests.ts # bookshelf/bookshelf.d.ts # enzyme/enzyme-tests.tsx # enzyme/enzyme.d.ts # escodegen/escodegen-tests.ts # helmet/helmet.d.ts # joi/joi.d.ts # knex/knex-tests.ts # moment/index.d.ts # mongoose/index.d.ts # pg/pg.d.ts # react-select/react-select-tests.tsx # soap/index.d.ts # ssh2/ssh2.d.ts # turf/turf-tests.ts # underscore.string/underscore.string.d.ts
64 lines
1.3 KiB
TypeScript
64 lines
1.3 KiB
TypeScript
|
|
/// <reference types="react" />
|
|
|
|
import Reflux = require("reflux");
|
|
import React = require("react");
|
|
|
|
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: function () {
|
|
|
|
// Register statusUpdate action
|
|
this.listenTo(asyncActions.fireBall, this.onFireBall);
|
|
},
|
|
// Callback
|
|
onFireBall: function (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: function () {
|
|
this.listenToMany(actions);
|
|
},
|
|
onFireBall: function () {
|
|
// whoooosh!
|
|
},
|
|
onMagicMissile: function () {
|
|
// bzzzzapp!
|
|
}
|
|
});
|
|
|
|
var ReactComponent = {
|
|
mixins: [Reflux.ListenerMixin]
|
|
}; |