Skip to content

Commit a86c138

Browse files
committed
Merge pull request #95 from f/trigger_mixin
Add a trigger mixin
2 parents f0dc059 + fe27310 commit a86c138

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "delorean",
3-
"version": "0.9.7",
3+
"version": "0.9.8",
44
"description": "Flux Library",
55
"main": "src/delorean.js",
66
"scripts": {

src/delorean.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,21 @@
566566

567567
// ## Built-in React Mixin
568568
DeLorean.Flux.mixins = {
569+
570+
// This mixin adds the this.trigger method to the component
571+
// Components can then trigger actions in flux w/out watching stores and having their state
572+
trigger: {
573+
574+
componentWillMount: function () {
575+
this.__dispatcher = __findDispatcher(this);
576+
},
577+
578+
trigger: function () {
579+
this.__dispatcher.emit.apply(this.__dispatcher, arguments);
580+
}
581+
582+
},
583+
569584
// It should be inserted to the React components which
570585
// used in Flux.
571586
// Simply `mixin: [Flux.mixins.storeListener]` will work.

0 commit comments

Comments
 (0)