@feathersjs/socket-commons
Advanced tools
Comparing version 3.0.1 to 3.1.0
# Change Log | ||
## [v3.0.1](https://github.com/feathersjs/socket-commons/tree/v3.0.1) (2017-11-03) | ||
[Full Changelog](https://github.com/feathersjs/socket-commons/compare/v3.0.0...v3.0.1) | ||
**Closed issues:** | ||
- Allow socket calls without params and callback [\#54](https://github.com/feathersjs/socket-commons/issues/54) | ||
**Merged pull requests:** | ||
- Allow socket calls without query and callback [\#55](https://github.com/feathersjs/socket-commons/pull/55) ([daffl](https://github.com/daffl)) | ||
## [v3.0.0](https://github.com/feathersjs/socket-commons/tree/v3.0.0) (2017-11-01) | ||
@@ -4,0 +15,0 @@ [Full Changelog](https://github.com/feathersjs/socket-commons/compare/v3.0.0-pre.7...v3.0.0) |
const debug = require('debug')('@feathersjs/socket-commons/channels'); | ||
const { get, compact, flattenDeep } = require('lodash'); | ||
const { get, compact, flattenDeep, noop } = require('lodash'); | ||
const CombinedChannel = require('./channel/combined'); | ||
@@ -43,15 +43,21 @@ const { channelMixin, publishMixin, keys } = require('./mixins'); | ||
const appPublishers = app[PUBLISHERS]; | ||
const publishers = compact([ | ||
// This will return the first publisher list that is not empty | ||
// In the following precedence | ||
const callback = [ | ||
// 1. Service publisher for a specific event | ||
get(servicePublishers, event), | ||
// 2. Service publisher for all events | ||
get(servicePublishers, ALL_EVENTS), | ||
get(servicePublishers, event), | ||
get(appPublishers, ALL_EVENTS), | ||
get(appPublishers, event) | ||
]); | ||
// 3. App publishers for a specific event | ||
get(appPublishers, event), | ||
// 4. App publishers for all events | ||
get(appPublishers, ALL_EVENTS) | ||
].find(current => typeof current === 'function') || noop; | ||
Promise.all(publishers.map(callback => | ||
Promise.resolve(callback(data, hook)) | ||
)).then(results => { | ||
const channel = new CombinedChannel(compact(flattenDeep(results))); | ||
Promise.resolve(callback(data, hook)).then(result => { | ||
const channel = Array.isArray(result) | ||
? new CombinedChannel(compact(flattenDeep(result))) | ||
: result; | ||
if (channel.length > 0) { | ||
if (channel && channel.length > 0) { | ||
app.emit('publish', event, channel, hook); | ||
@@ -58,0 +64,0 @@ } else { |
{ | ||
"name": "@feathersjs/socket-commons", | ||
"description": "Shared functionality for websocket providers", | ||
"version": "3.0.1", | ||
"version": "3.1.0", | ||
"homepage": "https://github.com/feathersjs/socket-commons", | ||
@@ -6,0 +6,0 @@ "main": "lib/", |
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
33627
425
13