Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

redbone

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

redbone - npm Package Compare versions

Comparing version 1.0.9 to 1.0.10

25

client/getServerDispatchMidddleware.js
const isPlainObject = require('lodash/isPlainObject');
const merge = require('lodash/merge');
const assign = require('lodash/assign');
var server_regexp = /^@@server\/.*?$/i
var defaultOptions = {
next: false
next: false,
exclude: null
}

@@ -11,8 +12,10 @@

* Process client -> server dispatching
* @param {Socket} io socket.io connection to server
* @param {Object} options action processing options
* @return {Mided} do not use it
* @param {Socket} io - socket.io connection to server
* @param {Object} options - action processing options
* @param {Boolean} options.next - process server action or not
* @param {Array} options.exclude - list of disallowed server action types
* @return {Mided} - do not use it
*/
module.exports = function getServerDispatchMiddleware(io, options) {
let middlewareOptions = options ? merge(defaultOptions, options) : defaultOptions;
let middlewareOptions = options ? assign(defaultOptions, options) : defaultOptions;

@@ -25,6 +28,8 @@ return function () {

if (server_regexp.test(action.type)) {
if (middlewareOptions.next === false) {
return io.emit('dispatch', action);
} else {
io.emit('dispatch', action);
if (!middlewareOptions.exclude || middlewareOptions.exclude.indexOf(action.type) === -1) {
if (middlewareOptions.next === false) {
return io.emit('dispatch', action);
} else {
io.emit('dispatch', action);
}
}

@@ -31,0 +36,0 @@ }

2

package.json
{
"name": "redbone",
"version": "1.0.9",
"version": "1.0.10",
"description": "Polymorphic library for two way redux dispatching",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -57,4 +57,13 @@ # redbone

`serverDispatchMiddleware` takes options as second parameter. If you want to pass server-side actions to store set `next` property as `true`, but if you want to exclude some actions from passing, set array of type to `exclude` property:
```
middlewares.unshift(serverDispatchMiddleware(io, {
next: true,
exclude: [TYPES.EXCLUDED_TYPE, TYPES.EXCLUDED_TYPE_TOO]
}));
```
## Watchers
documentation comming soon
Look at server side example
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc