Comparing version 1.0.6 to 1.0.7
@@ -12,3 +12,5 @@ const isFunction = require('lodash/isFunction'); | ||
function dispatcher(socket, action) { | ||
socket = new Socket(socket); | ||
if (!(socket instanceof Socket)) { | ||
socket = new Socket(socket); | ||
} | ||
//Если список middleware пуст | ||
@@ -15,0 +17,0 @@ if (!dispatcher.__fns.length) return; |
@@ -21,4 +21,5 @@ const path = require('path'); | ||
dispatcher(socket, { type: '@@server/CONNECTION' }); | ||
socket.on('dispatch', (action) => dispatcher(socket, action)); | ||
socket.on('disconnect', () => dispatcher(socket, { type: '@@server/DISCONNECT' })); | ||
const synteticSocket = new Socket(socket); | ||
socket.on('dispatch', (action) => dispatcher(synteticSocket, action)); | ||
socket.on('disconnect', () => dispatcher(synteticSocket, { type: '@@server/DISCONNECT' })); | ||
} | ||
@@ -25,0 +26,0 @@ |
const isString = require('lodash/isString'); | ||
const isPlainObject = require('lodash/isPlainObject'); | ||
const isNull = require('lodash/isNull'); | ||
@@ -22,2 +24,3 @@ /** | ||
this.nativeSocket = socket; | ||
this.storage = {}; | ||
} | ||
@@ -32,2 +35,17 @@ | ||
} | ||
set(key, value = null) { | ||
if (isString(key)) { | ||
value = { [key]: value } | ||
} else if (isPlainObject(key)) { | ||
value = key; | ||
} else return; | ||
this.storage = Object.assign(this.storage, value); | ||
} | ||
get(key = null) { | ||
if (!isNull(key)) return this.storage; | ||
return this.storage[key]; | ||
} | ||
/** | ||
@@ -34,0 +52,0 @@ * dispatch action to client |
{ | ||
"name": "redbone", | ||
"version": "1.0.6", | ||
"version": "1.0.7", | ||
"description": "Polymorphic library for two way redux dispatching", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
16971
386