feathers-channels
Channel functionality for real-time event publishing
About
feathers-channels
provides channel functionality for bi-directional Feathers service providers. It is e.g. used by the Socket.io and Primus provider to quickly determine what messages to send to connected clients.
npm install feathers-channels --save
Documentation
app.channel(... names)
Returns a named or combined channel object.
const channel = app; // return a `test` channel channel; // join a channelchannel; // leave a channel channel // return a new channel with filtered connectionschannellength // return the number of connectionschannelconnections // all connections in this channel const combined = app; // return a combined channel combined; // join the `test` and `other` channelcombined; // leave the `test` and `other` channel channel // return a new channel with filtered connections (connections will only be iterated once)combinedlength // return the number of connectionscombinedconnections // all connections in the combined channel (if a connection is in multiple channels it will only show once)
app.service('servicename').publish(event, callback)
, app.service('servicename').publish(callback)
Register a publishing callback for a service and event (or all events) that returns a (named or combined) channel.
app; // `created` event for the `test` serviceapp; // `created` event for the `test` service, sending different data to two different channelsapp; // All events for all servicesapp; // All `created` events for all servicesapp; // All events for `test` serviceapp;
app.on('publish', function(event, channel, hook) {})
An event that will be sent every time a service event that has connections to publish to happens. channel
is a combined channel with all connections to publish the event to.
Note: If there are no channels or connections the
publish
event will not be sent.
app;
License
Copyright (c) 2017
Licensed under the MIT license.