Skip to content

Commit 6adbc41

Browse files
committed
Add subscribeTo method in order to track eventStreams that need to be unsubscribed from when the component unmounts
1 parent 7127206 commit 6adbc41

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/react-bacon.js

+5
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ module.exports.BaconMixin = ((function(){
4747
}
4848
return bus;
4949
},
50+
subscribeTo: function(unsub) {
51+
var bacon = this._bacon = this._bacon || {};
52+
var unsubscribers = bacon.unsubscribers = bacon.unsubscribers || [];
53+
unsubscribers.push(unsub);
54+
},
5055
plug: function(stream, stateKey) {
5156
var unsubscribe;
5257
var component = this;

0 commit comments

Comments
 (0)