Abhinav Rastogi
Web Developer, Photographer, Designer. Loves Pink Floyd, Coldplay, Beatles. Travelling is fun, science is awesome!
client 1
other clients
dispatch(payload, broadcast = true)
Dispatcher.setSocket = function(socket) {
// keep a reference to the socket
Dispatcher._socket = socket;
// fire action on relevant socket event
Dispatcher._socket.on('flux_action', payload => {
Dispatcher.dispatch(payload, false);
});
};
Dispatcher.dispatch = function(payload, broadcast = true) {
if(broadcast) {
Dispatcher._socket.emit('flux_action', payload);
}
// call original dispatcher, return dispatch token
return _dispatch(payload);
};
By Abhinav Rastogi
Web Developer, Photographer, Designer. Loves Pink Floyd, Coldplay, Beatles. Travelling is fun, science is awesome!