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

fun-model

Package Overview
Dependencies
Maintainers
1
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fun-model - npm Package Compare versions

Comparing version 1.0.5 to 1.1.0

CHANGELOG.md

8

package.json
{
"name": "fun-model",
"version": "1.0.5",
"version": "1.1.0",
"description": "fun-model is pure functional implementation of FLUX architecture.",

@@ -25,3 +25,5 @@ "main": "./index.js",

},
"dependencies": {},
"dependencies": {
"ts-loader": "^0.8.2"
},
"devDependencies": {

@@ -35,2 +37,2 @@ "gulp": "3.9.0",

"license": "MIT"
}
}

@@ -11,3 +11,3 @@ import * as s from './store';

validateRenderCallback();
if (changeState(unifyCursor(cursor, params), handler, params)) {
if (changeQueuedState(unifyCursor(cursor, params), handler, params)) {
render();

@@ -28,3 +28,3 @@ d.log('Rendering invoked...');

let pair = pairs[i];
if (changeState(pair.cursor, pair.handler, params))
if (changeQueuedState(pair.cursor, pair.handler, params))
changed = true;

@@ -41,11 +41,7 @@ }

let c = unifyCursor(cursor, params);
let oldState = s.getState(c);
let newState = handler(oldState, params);
if (oldState !== newState) {
s.setState(c, newState);
d.log('Global state has been changed.');
if (changeQueuedState(c, handler, params)) {
render();
d.log('Rendering invoked...');
}
f(newState);
f(s.getState(c));
}, 0);

@@ -59,2 +55,18 @@ });

}
let isStateLocked = false;
let queueOfHandlers = [];
function changeQueuedState(cursor, handler, params) {
if (isStateLocked) {
queueOfHandlers = [{ cursor, handler, params }, ...queueOfHandlers];
return;
}
isStateLocked = true;
let isStateChanged = changeState(cursor, handler, params);
let n;
while (n = queueOfHandlers.pop())
isStateChanged = changeState(n.cursor, n.handler, n.params) || isStateChanged;
isStateLocked = false;
isStateChanged && d.log('Global state has been changed.');
return isStateChanged;
}
function changeState(cursor, handler, params) {

@@ -66,4 +78,3 @@ let oldState = s.getState(cursor);

s.setState(cursor, newState);
d.log('Global state has been changed.');
return true;
}

@@ -23,3 +23,3 @@ import * as s from './store';

validateRenderCallback();
if (changeState(unifyCursor<TState, TParams>(cursor, params), handler, params)) {
if (changeQueuedState(unifyCursor<TState, TParams>(cursor, params), handler, params)) {
render();

@@ -47,3 +47,3 @@ d.log('Rendering invoked...');

let pair = pairs[i];
if (changeState(pair.cursor, pair.handler, params))
if (changeQueuedState(pair.cursor, pair.handler, params))
changed = true;

@@ -62,11 +62,7 @@ }

let c = unifyCursor<TState, TParams>(cursor, params);
let oldState = s.getState(c);
let newState = handler(oldState, params);
if (oldState !== newState) {
s.setState(c, newState);
d.log('Global state has been changed.');
if (changeQueuedState(c, handler, params)) {
render();
d.log('Rendering invoked...');
}
f(newState);
f(s.getState(c));
}, 0);

@@ -82,2 +78,26 @@ });

interface IQueuedHandling<TState extends s.IState, TParams> {
cursor: s.ICursor<TState>;
handler: (state: TState, t?: TParams) => TState;
params: TParams;
}
let isStateLocked = false;
let queueOfHandlers: IQueuedHandling<s.IState, Object>[] = [];
function changeQueuedState<TState extends s.IState, TParams>(cursor: s.ICursor<TState>, handler: (state: TState, t?: TParams) => TState, params: TParams)
: boolean {
if (isStateLocked) {
queueOfHandlers = [{ cursor, handler, params }, ...queueOfHandlers];
return;
}
isStateLocked = true;
let isStateChanged = changeState(cursor, handler, params);
let n;
while (n = queueOfHandlers.pop())
isStateChanged = changeState(n.cursor, n.handler, n.params) || isStateChanged;
isStateLocked = false;
isStateChanged && d.log('Global state has been changed.');
return isStateChanged;
}
function changeState<TState extends s.IState, TParams>(cursor: s.ICursor<TState>, handler: (state: TState, t?: TParams) => TState, params: TParams)

@@ -90,4 +110,3 @@ : boolean {

s.setState(cursor, newState);
d.log('Global state has been changed.');
return true;
}
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