Skip to content

Commit

Permalink
Fix the event name and add some channel debug statements (#49)
Browse files Browse the repository at this point in the history
  • Loading branch information
daffl committed Aug 22, 2018
1 parent ca4bdf2 commit 8a31f52
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
5 changes: 5 additions & 0 deletions packages/transport-commons/lib/channels/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const debug = require('debug')('feathers-socket-commons:channels');
const { get, compact, flattenDeep } = require('lodash');
const CombinedChannel = require('./channel/combined');
const { channelMixin, publishMixin, keys } = require('./mixins');
Expand Down Expand Up @@ -35,6 +36,8 @@ function channels () {
hook = { path, service, app, result: data };
}

debug('Publishing event', event, hook.path);

const servicePublishers = service[PUBLISHERS];
const appPublishers = app[PUBLISHERS];
const publishers = compact([
Expand All @@ -51,6 +54,8 @@ function channels () {

if (channel.length > 0) {
app.emit('publish', event, channel, hook);
} else {
debug('No connections to publish to');
}
});
});
Expand Down
5 changes: 5 additions & 0 deletions packages/transport-commons/lib/channels/mixins.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const debug = require('debug')('feathers-socket-commons:channels/mixins');
const Channel = require('./channel/base');
const CombinedChannel = require('./channel/combined');

Expand All @@ -16,6 +17,8 @@ exports.channelMixin = function channelMixin () {
[CHANNELS]: {},

channel (...names) {
debug('Returning channels', names);

if (names.length === 0) {
throw new Error('app.channel needs at least one channel name');
}
Expand Down Expand Up @@ -43,6 +46,8 @@ exports.publishMixin = function publishMixin () {
[PUBLISHERS]: {},

publish (event, callback) {
debug('Registering publisher', event);

if (!callback && typeof event === 'function') {
callback = event;
event = ALL_EVENTS;
Expand Down
2 changes: 1 addition & 1 deletion packages/transport-commons/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module.exports = function ({ done, emit, socketKey, getParams }) {

// Event dispatching (through `feathers-channels`)
app.configure(channels());
app.on('publish', getDispatcher('emit', socketKey));
app.on('publish', getDispatcher(emit, socketKey));

// `connection` event
done.then(provider => provider.on('connection', socket =>
Expand Down

0 comments on commit 8a31f52

Please sign in to comment.