-
-
Save iddar/6f7e513b9da0a75bfced to your computer and use it in GitHub Desktop.
Relux Join // source http://jsbin.com/tahufucohu
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 characters
<!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 characters
/* | |
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'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment