pusher-redux
Advanced tools
Comparing version 0.3.6 to 0.3.7
@@ -36,2 +36,5 @@ 'use strict'; | ||
} | ||
if (options.additionalParams) { | ||
result.additionalParams = options.additionalParams | ||
} | ||
return result; | ||
@@ -94,3 +97,3 @@ }; | ||
module.exports.subscribe = function (channelName, eventName, actionType) { | ||
module.exports.subscribe = function (channelName, eventName, actionType, additionalParams) { | ||
addToQueue(function () { | ||
@@ -108,3 +111,3 @@ var channel = config.socket.channel(channelName) || config.socket.subscribe(channelName); | ||
eventSubs[actionType] = function (data) { | ||
config.store.dispatch(pusherAction({ actionType: actionType, channelName: channelName, eventName: eventName, data: data })); | ||
config.store.dispatch(pusherAction({ actionType: actionType, channelName: channelName, eventName: eventName, data: data, additionalParams: additionalParams })); | ||
}; | ||
@@ -111,0 +114,0 @@ channel.bind(eventName, eventSubs[actionType]); |
{ | ||
"name": "pusher-redux", | ||
"version": "0.3.6", | ||
"version": "0.3.7", | ||
"description": "Integration of Pusher into Redux", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -39,13 +39,25 @@ # pusher-redux | ||
} | ||
componentWillUnmount() { | ||
this.unsubscribe(); | ||
} | ||
// upon receiving event 'some_event' for channel 'some_channel' pusher-redux is going to dispatch action NEW_ORDER | ||
// add additional params which will be merged into pusherAction and dispatched along with it | ||
// you can bind multiple actions for the same event and it's gonna dispatch all of them | ||
subscribe() { | ||
subscribe('some_channel', 'some_event', NEW_ORDER); | ||
// your additionalParams | ||
const additionalParams = () => {} | ||
subscribe('some_channel', 'some_event', NEW_ORDER, additionalParams); | ||
// access it within the data object = { | ||
// type: String, | ||
// channel: String, | ||
// event: String, | ||
// data: Object, | ||
// additionalParams: Any | ||
// } | ||
} | ||
unsubscribe() { | ||
@@ -52,0 +64,0 @@ unsubscribe('some_channel', 'some_event', NEW_ORDER); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
18489
133
165
8