New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@aha-app/react-easy-state

Package Overview
Dependencies
Maintainers
38
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aha-app/react-easy-state - npm Package Compare versions

Comparing version 0.0.8-development to 0.0.9-development

94

dist/cjs.es5.js

@@ -248,6 +248,4 @@ 'use strict';

if (!taskPending) {
console.log("Batching setState ".concat(viewIndex));
taskPending = true;
queueMicrotask(function () {
console.log("Running setState ".concat(viewIndex));
var batchesToRun = batchesPending;

@@ -257,14 +255,12 @@ taskPending = false;

reactPlatform_cjs.unstable_batchedUpdates(function () {
return Object.values(batchesToRun).forEach(function (fn) {
return fn();
return Object.values(batchesToRun).forEach(function (setStateFn) {
return setStateFn();
});
});
});
} else {
console.log("Already batched setState ".concat(viewIndex));
}
}
} // No need to trigger an update for this view since it has been removed.
function clearBatch(viewIndex) {
console.log("Clearing batch ".concat(viewIndex));
delete batchesPending[viewIndex];

@@ -280,3 +276,5 @@ }

ReactiveComp = function ReactiveComp(props) {
var viewIndex = viewIndexCounter++; // use a dummy setState to update the component
// Unique ID for each view instance.
viewIndexCounter += 1;
var viewIndex = viewIndexCounter; // use a dummy setState to update the component

@@ -293,3 +291,2 @@ var _useState = react.useState(),

return batchSetState(viewIndex, function () {
console.log(" setState function ".concat(viewIndex, " ").concat(Comp.name));
setState({});

@@ -306,2 +303,3 @@ });

return function () {
// We don't need to trigger a render after the component is removed.
clearBatch(viewIndex);

@@ -334,4 +332,6 @@ observerUtil.unobserve(render);

_this = _possibleConstructorReturn(this, _getPrototypeOf(ReactiveClassComp).call(this, props, context));
_this.viewIndex = viewIndexCounter++;
_this = _possibleConstructorReturn(this, _getPrototypeOf(ReactiveClassComp).call(this, props, context)); // Unique ID for each class insance.
viewIndexCounter += 1;
_this.viewIndex = viewIndexCounter;
_this.state = _this.state || {};

@@ -394,4 +394,5 @@ _this.state[COMPONENT] = _assertThisInitialized(_this); // create a reactive render for the component

_get(_getPrototypeOf(ReactiveClassComp.prototype), "componentWillUnmount", this).call(this);
}
} // We don't need to trigger a render.
clearBatch(this.viewIndex); // clean up memory used by Easy State

@@ -510,27 +511,3 @@

}
/* CJW
function batchMethodCallbacks(obj, method) {
const descriptor = Object.getOwnPropertyDescriptor(obj, method);
if (
descriptor &&
descriptor.writable &&
typeof descriptor.value === 'function'
) {
obj[method] = new Proxy(descriptor.value, {
apply(target, ctx, args) {
return Reflect.apply(target, ctx, args.map(batchFn));
},
});
}
}
*/
/* CJW
// batched obj.addEventListener(cb) like callbacks
function batchMethodsCallbacks(obj, methods) {
methods.forEach(method => batchMethodCallbacks(obj, method));
}
*/
function batchMethod(obj, method) {

@@ -564,47 +541,4 @@ var descriptor = Object.getOwnPropertyDescriptor(obj, method);

return obj;
} // do a sync batching for the most common task sources
// this should be removed when React's own batching is improved in the future
/* CJW
// batch timer functions
batchMethodsCallbacks(globalObj, [
'setTimeout',
'setInterval',
'requestAnimationFrame',
'requestIdleCallback',
]);
*/
/* CJW
if (globalObj.Promise) {
batchMethodsCallbacks(Promise.prototype, ['then', 'catch']);
}
*/
// Event listener batching causes an input caret jumping bug:
// https://github.com/RisingStack/react-easy-state/issues/92.
// This part has to be commented out to prevent that bug.
// React batches setStates in its event listeners anyways
// so this commenting this part out is not a huge issue.
// batch addEventListener calls
/* if (globalObj.EventTarget) {
batchMethodsCallbacks(EventTarget.prototype, [
'addEventListener',
'removeEventListener',
]);
} */
/* CJW
// this batches websocket event handlers
if (globalObj.WebSocket) {
batchMethods(WebSocket.prototype, [
'onopen',
'onmessage',
'onerror',
'onclose',
]);
}
*/
// HTTP event handlers are usually wrapped by Promises, which is covered above
function createStore(obj) {

@@ -611,0 +545,0 @@ return batchMethods(observerUtil.observable(typeof obj === 'function' ? obj() : obj));

@@ -11,2 +11,3 @@ 'use strict';

/* eslint camelcase: 0 */
let isInsideFunctionComponent = false;

@@ -37,18 +38,14 @@ let isInsideClassComponentRender = false;

if (!taskPending) {
console.log(`Batching setState ${viewIndex}`);
taskPending = true;
queueMicrotask(() => {
console.log(`Running setState ${viewIndex}`);
const batchesToRun = batchesPending;
taskPending = false;
batchesPending = {};
reactPlatform_cjs.unstable_batchedUpdates(() => Object.values(batchesToRun).forEach(fn => fn()));
reactPlatform_cjs.unstable_batchedUpdates(() => Object.values(batchesToRun).forEach(setStateFn => setStateFn()));
});
} else {
console.log(`Already batched setState ${viewIndex}`);
}
}
} // No need to trigger an update for this view since it has been removed.
function clearBatch(viewIndex) {
console.log(`Clearing batch ${viewIndex}`);
delete batchesPending[viewIndex];

@@ -64,3 +61,5 @@ }

ReactiveComp = props => {
const viewIndex = viewIndexCounter++; // use a dummy setState to update the component
// Unique ID for each view instance.
viewIndexCounter += 1;
const viewIndex = viewIndexCounter; // use a dummy setState to update the component

@@ -72,3 +71,2 @@ const [, setState] = react.useState(); // create a memoized reactive wrapper of the original component (render)

scheduler: () => batchSetState(viewIndex, () => {
console.log(` setState function ${viewIndex} ${Comp.name}`);
setState({});

@@ -83,2 +81,3 @@ }),

return () => {
// We don't need to trigger a render after the component is removed.
clearBatch(viewIndex);

@@ -105,4 +104,6 @@ observerUtil.unobserve(render);

constructor(props, context) {
super(props, context);
this.viewIndex = viewIndexCounter++;
super(props, context); // Unique ID for each class insance.
viewIndexCounter += 1;
this.viewIndex = viewIndexCounter;
this.state = this.state || {};

@@ -171,4 +172,5 @@ this.state[COMPONENT] = this; // create a reactive render for the component

super.componentWillUnmount();
}
} // We don't need to trigger a render.
clearBatch(this.viewIndex); // clean up memory used by Easy State

@@ -315,27 +317,3 @@

}
/* CJW
function batchMethodCallbacks(obj, method) {
const descriptor = Object.getOwnPropertyDescriptor(obj, method);
if (
descriptor &&
descriptor.writable &&
typeof descriptor.value === 'function'
) {
obj[method] = new Proxy(descriptor.value, {
apply(target, ctx, args) {
return Reflect.apply(target, ctx, args.map(batchFn));
},
});
}
}
*/
/* CJW
// batched obj.addEventListener(cb) like callbacks
function batchMethodsCallbacks(obj, methods) {
methods.forEach(method => batchMethodCallbacks(obj, method));
}
*/
function batchMethod(obj, method) {

@@ -369,47 +347,4 @@ const descriptor = Object.getOwnPropertyDescriptor(obj, method);

return obj;
} // do a sync batching for the most common task sources
// this should be removed when React's own batching is improved in the future
/* CJW
// batch timer functions
batchMethodsCallbacks(globalObj, [
'setTimeout',
'setInterval',
'requestAnimationFrame',
'requestIdleCallback',
]);
*/
/* CJW
if (globalObj.Promise) {
batchMethodsCallbacks(Promise.prototype, ['then', 'catch']);
}
*/
// Event listener batching causes an input caret jumping bug:
// https://github.com/RisingStack/react-easy-state/issues/92.
// This part has to be commented out to prevent that bug.
// React batches setStates in its event listeners anyways
// so this commenting this part out is not a huge issue.
// batch addEventListener calls
/* if (globalObj.EventTarget) {
batchMethodsCallbacks(EventTarget.prototype, [
'addEventListener',
'removeEventListener',
]);
} */
/* CJW
// this batches websocket event handlers
if (globalObj.WebSocket) {
batchMethods(WebSocket.prototype, [
'onopen',
'onmessage',
'onerror',
'onclose',
]);
}
*/
// HTTP event handlers are usually wrapped by Promises, which is covered above
function createStore(obj) {

@@ -416,0 +351,0 @@ return batchMethods(observerUtil.observable(typeof obj === 'function' ? obj() : obj));

@@ -245,6 +245,4 @@ import { useState, memo, useMemo, useEffect, Component } from 'react';

if (!taskPending) {
console.log("Batching setState ".concat(viewIndex));
taskPending = true;
queueMicrotask(function () {
console.log("Running setState ".concat(viewIndex));
var batchesToRun = batchesPending;

@@ -254,14 +252,12 @@ taskPending = false;

unstable_batchedUpdates(function () {
return Object.values(batchesToRun).forEach(function (fn) {
return fn();
return Object.values(batchesToRun).forEach(function (setStateFn) {
return setStateFn();
});
});
});
} else {
console.log("Already batched setState ".concat(viewIndex));
}
}
} // No need to trigger an update for this view since it has been removed.
function clearBatch(viewIndex) {
console.log("Clearing batch ".concat(viewIndex));
delete batchesPending[viewIndex];

@@ -277,3 +273,5 @@ }

ReactiveComp = function ReactiveComp(props) {
var viewIndex = viewIndexCounter++; // use a dummy setState to update the component
// Unique ID for each view instance.
viewIndexCounter += 1;
var viewIndex = viewIndexCounter; // use a dummy setState to update the component

@@ -290,3 +288,2 @@ var _useState = useState(),

return batchSetState(viewIndex, function () {
console.log(" setState function ".concat(viewIndex, " ").concat(Comp.name));
setState({});

@@ -303,2 +300,3 @@ });

return function () {
// We don't need to trigger a render after the component is removed.
clearBatch(viewIndex);

@@ -331,4 +329,6 @@ unobserve(render);

_this = _possibleConstructorReturn(this, _getPrototypeOf(ReactiveClassComp).call(this, props, context));
_this.viewIndex = viewIndexCounter++;
_this = _possibleConstructorReturn(this, _getPrototypeOf(ReactiveClassComp).call(this, props, context)); // Unique ID for each class insance.
viewIndexCounter += 1;
_this.viewIndex = viewIndexCounter;
_this.state = _this.state || {};

@@ -391,4 +391,5 @@ _this.state[COMPONENT] = _assertThisInitialized(_this); // create a reactive render for the component

_get(_getPrototypeOf(ReactiveClassComp.prototype), "componentWillUnmount", this).call(this);
}
} // We don't need to trigger a render.
clearBatch(this.viewIndex); // clean up memory used by Easy State

@@ -507,27 +508,3 @@

}
/* CJW
function batchMethodCallbacks(obj, method) {
const descriptor = Object.getOwnPropertyDescriptor(obj, method);
if (
descriptor &&
descriptor.writable &&
typeof descriptor.value === 'function'
) {
obj[method] = new Proxy(descriptor.value, {
apply(target, ctx, args) {
return Reflect.apply(target, ctx, args.map(batchFn));
},
});
}
}
*/
/* CJW
// batched obj.addEventListener(cb) like callbacks
function batchMethodsCallbacks(obj, methods) {
methods.forEach(method => batchMethodCallbacks(obj, method));
}
*/
function batchMethod(obj, method) {

@@ -561,47 +538,4 @@ var descriptor = Object.getOwnPropertyDescriptor(obj, method);

return obj;
} // do a sync batching for the most common task sources
// this should be removed when React's own batching is improved in the future
/* CJW
// batch timer functions
batchMethodsCallbacks(globalObj, [
'setTimeout',
'setInterval',
'requestAnimationFrame',
'requestIdleCallback',
]);
*/
/* CJW
if (globalObj.Promise) {
batchMethodsCallbacks(Promise.prototype, ['then', 'catch']);
}
*/
// Event listener batching causes an input caret jumping bug:
// https://github.com/RisingStack/react-easy-state/issues/92.
// This part has to be commented out to prevent that bug.
// React batches setStates in its event listeners anyways
// so this commenting this part out is not a huge issue.
// batch addEventListener calls
/* if (globalObj.EventTarget) {
batchMethodsCallbacks(EventTarget.prototype, [
'addEventListener',
'removeEventListener',
]);
} */
/* CJW
// this batches websocket event handlers
if (globalObj.WebSocket) {
batchMethods(WebSocket.prototype, [
'onopen',
'onmessage',
'onerror',
'onclose',
]);
}
*/
// HTTP event handlers are usually wrapped by Promises, which is covered above
function createStore(obj) {

@@ -608,0 +542,0 @@ return batchMethods(observable(typeof obj === 'function' ? obj() : obj));

@@ -8,2 +8,3 @@ import { useState, memo, useMemo, useEffect, Component } from 'react';

/* eslint camelcase: 0 */
let isInsideFunctionComponent = false;

@@ -34,18 +35,14 @@ let isInsideClassComponentRender = false;

if (!taskPending) {
console.log(`Batching setState ${viewIndex}`);
taskPending = true;
queueMicrotask(() => {
console.log(`Running setState ${viewIndex}`);
const batchesToRun = batchesPending;
taskPending = false;
batchesPending = {};
unstable_batchedUpdates(() => Object.values(batchesToRun).forEach(fn => fn()));
unstable_batchedUpdates(() => Object.values(batchesToRun).forEach(setStateFn => setStateFn()));
});
} else {
console.log(`Already batched setState ${viewIndex}`);
}
}
} // No need to trigger an update for this view since it has been removed.
function clearBatch(viewIndex) {
console.log(`Clearing batch ${viewIndex}`);
delete batchesPending[viewIndex];

@@ -61,3 +58,5 @@ }

ReactiveComp = props => {
const viewIndex = viewIndexCounter++; // use a dummy setState to update the component
// Unique ID for each view instance.
viewIndexCounter += 1;
const viewIndex = viewIndexCounter; // use a dummy setState to update the component

@@ -69,3 +68,2 @@ const [, setState] = useState(); // create a memoized reactive wrapper of the original component (render)

scheduler: () => batchSetState(viewIndex, () => {
console.log(` setState function ${viewIndex} ${Comp.name}`);
setState({});

@@ -80,2 +78,3 @@ }),

return () => {
// We don't need to trigger a render after the component is removed.
clearBatch(viewIndex);

@@ -102,4 +101,6 @@ unobserve(render);

constructor(props, context) {
super(props, context);
this.viewIndex = viewIndexCounter++;
super(props, context); // Unique ID for each class insance.
viewIndexCounter += 1;
this.viewIndex = viewIndexCounter;
this.state = this.state || {};

@@ -168,4 +169,5 @@ this.state[COMPONENT] = this; // create a reactive render for the component

super.componentWillUnmount();
}
} // We don't need to trigger a render.
clearBatch(this.viewIndex); // clean up memory used by Easy State

@@ -312,27 +314,3 @@

}
/* CJW
function batchMethodCallbacks(obj, method) {
const descriptor = Object.getOwnPropertyDescriptor(obj, method);
if (
descriptor &&
descriptor.writable &&
typeof descriptor.value === 'function'
) {
obj[method] = new Proxy(descriptor.value, {
apply(target, ctx, args) {
return Reflect.apply(target, ctx, args.map(batchFn));
},
});
}
}
*/
/* CJW
// batched obj.addEventListener(cb) like callbacks
function batchMethodsCallbacks(obj, methods) {
methods.forEach(method => batchMethodCallbacks(obj, method));
}
*/
function batchMethod(obj, method) {

@@ -366,47 +344,4 @@ const descriptor = Object.getOwnPropertyDescriptor(obj, method);

return obj;
} // do a sync batching for the most common task sources
// this should be removed when React's own batching is improved in the future
/* CJW
// batch timer functions
batchMethodsCallbacks(globalObj, [
'setTimeout',
'setInterval',
'requestAnimationFrame',
'requestIdleCallback',
]);
*/
/* CJW
if (globalObj.Promise) {
batchMethodsCallbacks(Promise.prototype, ['then', 'catch']);
}
*/
// Event listener batching causes an input caret jumping bug:
// https://github.com/RisingStack/react-easy-state/issues/92.
// This part has to be commented out to prevent that bug.
// React batches setStates in its event listeners anyways
// so this commenting this part out is not a huge issue.
// batch addEventListener calls
/* if (globalObj.EventTarget) {
batchMethodsCallbacks(EventTarget.prototype, [
'addEventListener',
'removeEventListener',
]);
} */
/* CJW
// this batches websocket event handlers
if (globalObj.WebSocket) {
batchMethods(WebSocket.prototype, [
'onopen',
'onmessage',
'onerror',
'onclose',
]);
}
*/
// HTTP event handlers are usually wrapped by Promises, which is covered above
function createStore(obj) {

@@ -413,0 +348,0 @@ return batchMethods(observable(typeof obj === 'function' ? obj() : obj));

2

package.json
{
"name": "@aha-app/react-easy-state",
"version": "0.0.8-development",
"version": "0.0.9-development",
"description": "React state management with a minimal API. Made with ES6 Proxies.",

@@ -5,0 +5,0 @@ "main": "dist/cjs.es6.js",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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