Created
November 19, 2015 19:08
-
-
Save anonymous/22855b97157e96923af9 to your computer and use it in GitHub Desktop.
Revisions
-
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,121 @@ <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Relux Join</title> <script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.12.2/react.js"></script> <script src="https://rawgit.com/spoike/refluxjs/master/dist/reflux.js"></script> </head> <body> <div id="example"></div> <script id="jsbin-javascript"> /* https://github.com/spoike/refluxjs#using-the-listener-instance-methods */ // var action1 = Reflux.createAction(), // action2 = Reflux.createAction(), // action3 = Reflux.createAction(), // join = Reflux.joinTrailing(action1,action2,action3); // function hello(data){ // console.log('== hello =='); // console.log(data); // } // Reflux.createStore().listenTo(join,hello); // action1('a'); // action2('b'); // action3('c'); 'use strict'; var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } var ActionFactory = (function () { function ActionFactory() { _classCallCheck(this, ActionFactory); this.actions = {}; } _createClass(ActionFactory, [{ key: 'createAction', value: function createAction(model) { this.actions[model] = Reflux.createAction(); return this.actions[model]; } }, { key: 'getAction', value: function getAction(model) { return !!this.actions[model] ? this.actions[model] : this.createAction(model); } }]); return ActionFactory; })(); var acF = new ActionFactory(); function hello(data) { console.log('== ' + data + ' =='); } Reflux.createStore().listenTo(acF.getAction('msg'), hello); acF.getAction('msg')('lol'); </script> <script id="jsbin-source-javascript" type="text/javascript">/* https://github.com/spoike/refluxjs#using-the-listener-instance-methods */ // var action1 = Reflux.createAction(), // action2 = Reflux.createAction(), // action3 = Reflux.createAction(), // join = Reflux.joinTrailing(action1,action2,action3); // function hello(data){ // console.log('== hello =='); // console.log(data); // } // Reflux.createStore().listenTo(join,hello); // action1('a'); // action2('b'); // action3('c'); class ActionFactory { constructor(){ this.actions = {}; } createAction(model) { this.actions[model] = Reflux.createAction(); return this.actions[model]; } getAction(model) { return !!this.actions[model] ? this.actions[model] : this.createAction(model) ; } } var acF = new ActionFactory(); function hello(data){ console.log(`== ${data} ==`); } Reflux.createStore().listenTo(acF.getAction('msg'), hello); acF.getAction('msg')('lol');</script></body> </html> This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,57 @@ /* https://github.com/spoike/refluxjs#using-the-listener-instance-methods */ // var action1 = Reflux.createAction(), // action2 = Reflux.createAction(), // action3 = Reflux.createAction(), // join = Reflux.joinTrailing(action1,action2,action3); // function hello(data){ // console.log('== hello =='); // console.log(data); // } // Reflux.createStore().listenTo(join,hello); // action1('a'); // action2('b'); // action3('c'); 'use strict'; var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } var ActionFactory = (function () { function ActionFactory() { _classCallCheck(this, ActionFactory); this.actions = {}; } _createClass(ActionFactory, [{ key: 'createAction', value: function createAction(model) { this.actions[model] = Reflux.createAction(); return this.actions[model]; } }, { key: 'getAction', value: function getAction(model) { return !!this.actions[model] ? this.actions[model] : this.createAction(model); } }]); return ActionFactory; })(); var acF = new ActionFactory(); function hello(data) { console.log('== ' + data + ' =='); } Reflux.createStore().listenTo(acF.getAction('msg'), hello); acF.getAction('msg')('lol');