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

reshow-flux-base

Package Overview
Dependencies
Maintainers
1
Versions
132
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

reshow-flux-base - npm Package Compare versions

Comparing version 0.0.17 to 0.1.0

37

build/cjs/Dispatcher.js

@@ -1,29 +0,33 @@

'use strict';
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _classCallCheck2 = require('reshow-runtime/helpers/classCallCheck');
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var Dispatcher = function Dispatcher() {
var _this = this;
(0, _classCallCheck3.default)(this, Dispatcher);
this.cbs = [];
this.register = function (cb) {
(0, _classCallCheck2.default)(this, Dispatcher);
(0, _defineProperty2.default)(this, "cbs", []);
(0, _defineProperty2.default)(this, "register", function (cb) {
return _this.cbs.push(cb);
};
this.dispatch = function (payload, params) {
});
(0, _defineProperty2.default)(this, "dispatch", function (payload, params) {
if (!payload) {
payload = {};
}
if ('string' === typeof payload) {
payload = { type: payload, params: params };
payload = {
type: payload,
params: params
};
if (!params) {

@@ -33,9 +37,10 @@ delete payload.params;

}
_this.cbs.forEach(function (c) {
return c(payload);
});
};
});
};
exports.default = Dispatcher;
module.exports = exports.default;
var _default = Dispatcher;
exports.default = _default;

@@ -1,16 +0,17 @@

'use strict';
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
Object.defineProperty(exports, "__esModule", {
value: true
});
var _Store = require('./Store');
Object.defineProperty(exports, 'Store', {
Object.defineProperty(exports, "Store", {
enumerable: true,
get: function get() {
return _interopRequireDefault(_Store).default;
return _Store.default;
}
});
Object.defineProperty(exports, 'CHANGE', {
Object.defineProperty(exports, "CHANGE", {
enumerable: true,

@@ -21,12 +22,11 @@ get: function get() {

});
var _Dispatcher = require('./Dispatcher');
Object.defineProperty(exports, 'Dispatcher', {
Object.defineProperty(exports, "Dispatcher", {
enumerable: true,
get: function get() {
return _interopRequireDefault(_Dispatcher).default;
return _Dispatcher.default;
}
});
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _Store = _interopRequireWildcard(require("./Store"));
var _Dispatcher = _interopRequireDefault(require("./Dispatcher"));

@@ -1,27 +0,26 @@

'use strict';
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.CHANGE = undefined;
exports.CHANGE = exports.default = void 0;
var _classCallCheck2 = require('reshow-runtime/helpers/classCallCheck');
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _createClass2 = require('reshow-runtime/helpers/createClass');
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _createClass3 = _interopRequireDefault(_createClass2);
var _mitt = _interopRequireDefault(require("mitt"));
var _mitt = require('mitt');
var _mitt2 = _interopRequireDefault(_mitt);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var CHANGE = 'chg';
exports.CHANGE = CHANGE;
var Store = function () {
(0, _createClass3.default)(Store, [{
key: 'reduce',
var Store =
/*#__PURE__*/
function () {
(0, _createClass2.default)(Store, [{
key: "reduce",
value: function reduce() {

@@ -31,3 +30,3 @@ console.error('Not override reduce().');

}, {
key: 'getInitialState',
key: "getInitialState",
value: function getInitialState() {

@@ -37,3 +36,3 @@ console.error('Not override getInitialState().');

}, {
key: 'equals',
key: "equals",
value: function equals(one, two) {

@@ -47,19 +46,23 @@ return one === two;

(0, _classCallCheck3.default)(this, Store);
this.getState = function () {
(0, _classCallCheck2.default)(this, Store);
(0, _defineProperty2.default)(this, "getState", function () {
return _this._state;
};
});
(0, _defineProperty2.default)(this, "__invokeOnDispatch", function (action) {
var startingState = _this._state;
this.__invokeOnDispatch = function (action) {
var startingState = _this._state;
var endingState = _this.reduce(startingState, action);
if (endingState === undefined) {
console.error('reduce() return undefined.');
}
if (!_this.equals(startingState, endingState)) {
_this._state = endingState;
_this.emit(CHANGE);
}
var next = _this.nextEmits.slice(0);
_this.nextEmits = [];

@@ -69,16 +72,12 @@ next.forEach(function (emit) {

});
};
this.emit = function (e) {
});
(0, _defineProperty2.default)(this, "emit", function (e) {
return _this.mitt.emit(e);
};
this.addListener = function (listener, e) {
});
(0, _defineProperty2.default)(this, "addListener", function (listener, e) {
return _this.mitt.on(e, listener);
};
this.removeListener = function (listener, e) {
});
(0, _defineProperty2.default)(this, "removeListener", function (listener, e) {
return _this.mitt.off(e, listener);
};
});
dispatcher.register(this.__invokeOnDispatch);

@@ -88,15 +87,11 @@ this._state = this.reset();

(0, _createClass3.default)(Store, [{
key: 'reset',
(0, _createClass2.default)(Store, [{
key: "reset",
value: function reset() {
this.mitt = new _mitt2.default();
this.mitt = new _mitt.default();
this.nextEmits = [];
return this.getInitialState();
}
/* Following not extendable */
// mitt event
}]);

@@ -106,3 +101,3 @@ return Store;

exports.default = Store;
exports.CHANGE = CHANGE;
var _default = Store;
exports.default = _default;

@@ -1,2 +0,3 @@

import _classCallCheck from 'reshow-runtime/es/helpers/classCallCheck';
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";

@@ -8,14 +9,19 @@ var Dispatcher = function Dispatcher() {

this.cbs = [];
_defineProperty(this, "cbs", []);
this.register = function (cb) {
_defineProperty(this, "register", function (cb) {
return _this.cbs.push(cb);
};
});
this.dispatch = function (payload, params) {
_defineProperty(this, "dispatch", function (payload, params) {
if (!payload) {
payload = {};
}
if ('string' === typeof payload) {
payload = { type: payload, params: params };
payload = {
type: payload,
params: params
};
if (!params) {

@@ -25,8 +31,9 @@ delete payload.params;

}
_this.cbs.forEach(function (c) {
return c(payload);
});
};
});
};
export default Dispatcher;

@@ -1,19 +0,27 @@

import _classCallCheck from 'reshow-runtime/es/helpers/classCallCheck';
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
import _createClass from "@babel/runtime/helpers/esm/createClass";
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
import mitt from 'mitt';
var CHANGE = 'chg';
var Store = function () {
Store.prototype.reduce = function reduce() {
console.error('Not override reduce().');
};
var Store =
/*#__PURE__*/
function () {
_createClass(Store, [{
key: "reduce",
value: function reduce() {
console.error('Not override reduce().');
}
}, {
key: "getInitialState",
value: function getInitialState() {
console.error('Not override getInitialState().');
}
}, {
key: "equals",
value: function equals(one, two) {
return one === two;
}
}]);
Store.prototype.getInitialState = function getInitialState() {
console.error('Not override getInitialState().');
};
Store.prototype.equals = function equals(one, two) {
return one === two;
};
function Store(dispatcher) {

@@ -24,17 +32,23 @@ var _this = this;

this.getState = function () {
_defineProperty(this, "getState", function () {
return _this._state;
};
});
this.__invokeOnDispatch = function (action) {
_defineProperty(this, "__invokeOnDispatch", function (action) {
var startingState = _this._state;
var endingState = _this.reduce(startingState, action);
if (endingState === undefined) {
console.error('reduce() return undefined.');
}
if (!_this.equals(startingState, endingState)) {
_this._state = endingState;
_this.emit(CHANGE);
}
var next = _this.nextEmits.slice(0);
_this.nextEmits = [];

@@ -44,15 +58,15 @@ next.forEach(function (emit) {

});
};
});
this.emit = function (e) {
_defineProperty(this, "emit", function (e) {
return _this.mitt.emit(e);
};
});
this.addListener = function (listener, e) {
_defineProperty(this, "addListener", function (listener, e) {
return _this.mitt.on(e, listener);
};
});
this.removeListener = function (listener, e) {
_defineProperty(this, "removeListener", function (listener, e) {
return _this.mitt.off(e, listener);
};
});

@@ -63,14 +77,13 @@ dispatcher.register(this.__invokeOnDispatch);

Store.prototype.reset = function reset() {
this.mitt = new mitt();
this.nextEmits = [];
return this.getInitialState();
};
_createClass(Store, [{
key: "reset",
value: function reset() {
this.mitt = new mitt();
this.nextEmits = [];
return this.getInitialState();
}
/* Following not extendable */
/* Following not extendable */
}]);
// mitt event
return Store;

@@ -77,0 +90,0 @@ }();

{
"name": "reshow-flux-base",
"version": "0.0.17",
"version": "0.1.0",
"description": "Pure flux dispatch mechanism",

@@ -14,7 +14,7 @@ "main": "./build/cjs/index.js",

"dependencies": {
"mitt": "*",
"reshow-runtime": "*"
"@babel/runtime": "*",
"mitt": "*"
},
"devDependencies": {
"babel-cli": "^6.x",
"@babel/cli": "^7.x",
"chai": "*",

@@ -27,6 +27,6 @@ "mocha": "*",

"build": "npm run clean && npm run build:cjs && npm run build:es",
"build:cjs": "BABEL_ENV=build babel src -d build/cjs",
"build:es": "BABEL_ENV=es babel src -d build/es",
"build:cjs": "BABEL_ENV=build babel src -d build/cjs --root-mode upward",
"build:es": "BABEL_ENV=es babel src -d build/es --root-mode upward",
"build:test": "BABEL_ENV=build babel tests -d build/tests --root-mode upward",
"prepublishOnly": "npm run test && npm run build",
"build:test": "BABEL_ENV=build babel tests -d build/tests",
"test": "npm run build && npm run build:test && mocha 'build/tests/**/*.js'"

@@ -33,0 +33,0 @@ },

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