Comparing version 1.0.1 to 1.0.2
89
index.js
@@ -7,52 +7,63 @@ 'use strict'; | ||
exports.default = function (_ref) { | ||
var event$ = _ref.event$, | ||
commandHandler = _ref.commandHandler, | ||
store = _ref.store, | ||
api = _ref.api; | ||
var _react = require('react'); | ||
var store$ = new _Subject.Subject(); | ||
var _react2 = _interopRequireDefault(_react); | ||
var boundedMiddleware = function boundedMiddleware(store) { | ||
return function (next) { | ||
return function (action) { | ||
event$.next(action); | ||
return next(action); | ||
}; | ||
}; | ||
}; | ||
var _reactRedux = require('react-redux'); | ||
var reduxStore = store(boundedMiddleware); | ||
var _merge = require('rxjs/observable/merge'); | ||
reduxStore.subscribe(function () { | ||
store$.next(reduxStore.getState()); | ||
}); | ||
var _Subject = require('rxjs/Subject'); | ||
var command$ = new _Subject.Subject(); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
_merge.merge.apply(undefined, _toConsumableArray(forceArray(commandHandler(command$, store$)))).subscribe(function (e) { | ||
try { | ||
reduxStore.dispatch(e); | ||
} catch (e) { | ||
console.error(e); | ||
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } | ||
function forceArray(arr) { | ||
if (!Array.isArray(arr)) return [arr]; | ||
return arr; | ||
} | ||
exports.default = function (event$, command$) { | ||
return function (_ref) { | ||
var root = _ref.root, | ||
store = _ref.store, | ||
commandHandler = _ref.commandHandler, | ||
processManager = _ref.processManager; | ||
if (store) { | ||
var reduxDispatcher = store.dispatch; | ||
store.dispatch = function (event) { | ||
event$.next(event); | ||
}; | ||
event$.subscribe(reduxDispatcher); | ||
} | ||
}); | ||
return api({ | ||
store: reduxStore, | ||
sendCommand: function sendCommand(e) { | ||
return command$.next(e); | ||
if (commandHandler) { | ||
var store$ = new _Subject.Subject(); | ||
if (store) { | ||
store.subscribe(function () { | ||
store$.next(store.getState()); | ||
}); | ||
} | ||
var handlerArr = commandHandler(command$, store$); | ||
_merge.merge.apply(undefined, _toConsumableArray(forceArray(handlerArr))).subscribe(event$); | ||
} | ||
}); | ||
}; | ||
var _merge = require('rxjs/observable/merge'); | ||
if (processManager) { | ||
var dispatchCommand = function dispatchCommand(command) { | ||
command$.next(command); | ||
}; | ||
var _Subject = require('rxjs/Subject'); | ||
event$.subscribe(function (e) { | ||
processManager(e, dispatchCommand); | ||
}); | ||
} | ||
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } | ||
function forceArray(arr) { | ||
if (!Array.isArray(arr)) return [arr]; | ||
return arr; | ||
} | ||
if (root) { | ||
return function () { | ||
return _react2.default.createElement(_reactRedux.Provider, { store: store }, _react2.default.createElement(root)); | ||
}; | ||
} | ||
}; | ||
}; |
{ | ||
"name": "bounded", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "", | ||
@@ -32,4 +32,5 @@ "main": "index.js", | ||
"dependencies": { | ||
"react": "^15.5.4", | ||
"rxjs": "^5.3.0" | ||
} | ||
} |
@@ -0,1 +1,3 @@ | ||
import React from 'react' | ||
import { Provider } from 'react-redux' | ||
import { merge } from 'rxjs/observable/merge' | ||
@@ -9,31 +11,39 @@ import { Subject } from 'rxjs/Subject' | ||
export default function ({ event$, commandHandler, store, api }) { | ||
const store$ = new Subject() | ||
export default (event$, command$) => ({ root, store, commandHandler, processManager }) => { | ||
if (store) { | ||
const reduxDispatcher = store.dispatch | ||
store.dispatch = function (event) { | ||
event$.next(event) | ||
} | ||
event$.subscribe(reduxDispatcher) | ||
} | ||
const boundedMiddleware = store => next => action => { | ||
event$.next(action) | ||
return next(action) | ||
if (commandHandler) { | ||
const store$ = new Subject() | ||
if (store) { | ||
store.subscribe(function () { | ||
store$.next(store.getState()) | ||
}) | ||
} | ||
const handlerArr = commandHandler(command$, store$) | ||
merge(...forceArray(handlerArr)).subscribe(event$) | ||
} | ||
const reduxStore = store(boundedMiddleware) | ||
if (processManager) { | ||
const dispatchCommand = command => { | ||
command$.next(command) | ||
} | ||
reduxStore.subscribe(function () { | ||
store$.next(reduxStore.getState()) | ||
}) | ||
const command$ = new Subject() | ||
merge(...forceArray(commandHandler(command$, store$))) | ||
.subscribe(e => { | ||
try { | ||
reduxStore.dispatch(e) | ||
} catch (e) { | ||
console.error(e) | ||
} | ||
event$.subscribe(e => { | ||
processManager(e, dispatchCommand) | ||
}) | ||
} | ||
return api({ | ||
store: reduxStore, | ||
sendCommand: e => command$.next(e) | ||
}) | ||
if (root) { | ||
return () => ( | ||
React.createElement(Provider, {store: store}, | ||
React.createElement(root) | ||
) | ||
) | ||
} | ||
} |
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
4046
94
2
+ Addedreact@^15.5.4
+ Addedasap@2.0.6(transitive)
+ Addedcore-js@1.2.7(transitive)
+ Addedcreate-react-class@15.7.0(transitive)
+ Addedencoding@0.1.13(transitive)
+ Addedfbjs@0.8.18(transitive)
+ Addediconv-lite@0.6.3(transitive)
+ Addedis-stream@1.1.0(transitive)
+ Addedisomorphic-fetch@2.2.1(transitive)
+ Addedjs-tokens@4.0.0(transitive)
+ Addedloose-envify@1.4.0(transitive)
+ Addednode-fetch@1.7.3(transitive)
+ Addedobject-assign@4.1.1(transitive)
+ Addedpromise@7.3.1(transitive)
+ Addedprop-types@15.8.1(transitive)
+ Addedreact@15.7.0(transitive)
+ Addedreact-is@16.13.1(transitive)
+ Addedsafer-buffer@2.1.2(transitive)
+ Addedsetimmediate@1.0.5(transitive)
+ Addedua-parser-js@0.7.39(transitive)
+ Addedwhatwg-fetch@3.6.20(transitive)