@aha-app/react-easy-state
Advanced tools
Comparing version 0.0.11-development to 0.0.12-development
@@ -298,26 +298,22 @@ 'use strict'; | ||
function runBatch() { | ||
var batchesToRun = batchesPending; | ||
taskPending = false; | ||
batchesPending = {}; | ||
reactPlatform_cjs.unstable_batchedUpdates(function () { | ||
return Object.values(batchesToRun).forEach(function (setStateFn) { | ||
return setStateFn(); | ||
}); | ||
}); | ||
} | ||
function batchSetState(viewIndex, fn) { | ||
if (inEventLoop) { | ||
// If we are in the main event loop, React handles the batching | ||
// automatically, so we run the change immediately. Deferring the | ||
// update can cause unexpected cursor shifts in input elements, | ||
// since the change can't be tied back to the action: | ||
// https://github.com/facebook/react/issues/5386 | ||
fn(); | ||
return; | ||
} | ||
batchesPending[viewIndex] = fn; | ||
if (!taskPending) { | ||
taskPending = true; | ||
taskPending = true; // If we're in an event handler, we'll run the batch at the end of it. | ||
if (inEventLoop) return; | ||
queueMicrotask(function () { | ||
var batchesToRun = batchesPending; | ||
taskPending = false; | ||
batchesPending = {}; | ||
reactPlatform_cjs.unstable_batchedUpdates(function () { | ||
return Object.values(batchesToRun).forEach(function (setStateFn) { | ||
return setStateFn(); | ||
}); | ||
}); | ||
runBatch(); | ||
}); | ||
@@ -387,2 +383,6 @@ } | ||
fn.apply(ctx, args); | ||
if (taskPending) { | ||
runBatch(); | ||
} | ||
} finally { | ||
@@ -389,0 +389,0 @@ inEventLoop = false; |
@@ -42,22 +42,18 @@ 'use strict'; | ||
function runBatch() { | ||
const batchesToRun = batchesPending; | ||
taskPending = false; | ||
batchesPending = {}; | ||
reactPlatform_cjs.unstable_batchedUpdates(() => Object.values(batchesToRun).forEach(setStateFn => setStateFn())); | ||
} | ||
function batchSetState(viewIndex, fn) { | ||
if (inEventLoop) { | ||
// If we are in the main event loop, React handles the batching | ||
// automatically, so we run the change immediately. Deferring the | ||
// update can cause unexpected cursor shifts in input elements, | ||
// since the change can't be tied back to the action: | ||
// https://github.com/facebook/react/issues/5386 | ||
fn(); | ||
return; | ||
} | ||
batchesPending[viewIndex] = fn; | ||
if (!taskPending) { | ||
taskPending = true; | ||
taskPending = true; // If we're in an event handler, we'll run the batch at the end of it. | ||
if (inEventLoop) return; | ||
queueMicrotask(() => { | ||
const batchesToRun = batchesPending; | ||
taskPending = false; | ||
batchesPending = {}; | ||
reactPlatform_cjs.unstable_batchedUpdates(() => Object.values(batchesToRun).forEach(setStateFn => setStateFn())); | ||
runBatch(); | ||
}); | ||
@@ -120,2 +116,6 @@ } | ||
fn.apply(ctx, args); | ||
if (taskPending) { | ||
runBatch(); | ||
} | ||
} finally { | ||
@@ -122,0 +122,0 @@ inEventLoop = false; |
@@ -295,26 +295,22 @@ import { useState, memo, useMemo, useEffect, Component } from 'react'; | ||
function runBatch() { | ||
var batchesToRun = batchesPending; | ||
taskPending = false; | ||
batchesPending = {}; | ||
unstable_batchedUpdates(function () { | ||
return Object.values(batchesToRun).forEach(function (setStateFn) { | ||
return setStateFn(); | ||
}); | ||
}); | ||
} | ||
function batchSetState(viewIndex, fn) { | ||
if (inEventLoop) { | ||
// If we are in the main event loop, React handles the batching | ||
// automatically, so we run the change immediately. Deferring the | ||
// update can cause unexpected cursor shifts in input elements, | ||
// since the change can't be tied back to the action: | ||
// https://github.com/facebook/react/issues/5386 | ||
fn(); | ||
return; | ||
} | ||
batchesPending[viewIndex] = fn; | ||
if (!taskPending) { | ||
taskPending = true; | ||
taskPending = true; // If we're in an event handler, we'll run the batch at the end of it. | ||
if (inEventLoop) return; | ||
queueMicrotask(function () { | ||
var batchesToRun = batchesPending; | ||
taskPending = false; | ||
batchesPending = {}; | ||
unstable_batchedUpdates(function () { | ||
return Object.values(batchesToRun).forEach(function (setStateFn) { | ||
return setStateFn(); | ||
}); | ||
}); | ||
runBatch(); | ||
}); | ||
@@ -384,2 +380,6 @@ } | ||
fn.apply(ctx, args); | ||
if (taskPending) { | ||
runBatch(); | ||
} | ||
} finally { | ||
@@ -386,0 +386,0 @@ inEventLoop = false; |
@@ -39,22 +39,18 @@ import { useState, memo, useMemo, useEffect, Component } from 'react'; | ||
function runBatch() { | ||
const batchesToRun = batchesPending; | ||
taskPending = false; | ||
batchesPending = {}; | ||
unstable_batchedUpdates(() => Object.values(batchesToRun).forEach(setStateFn => setStateFn())); | ||
} | ||
function batchSetState(viewIndex, fn) { | ||
if (inEventLoop) { | ||
// If we are in the main event loop, React handles the batching | ||
// automatically, so we run the change immediately. Deferring the | ||
// update can cause unexpected cursor shifts in input elements, | ||
// since the change can't be tied back to the action: | ||
// https://github.com/facebook/react/issues/5386 | ||
fn(); | ||
return; | ||
} | ||
batchesPending[viewIndex] = fn; | ||
if (!taskPending) { | ||
taskPending = true; | ||
taskPending = true; // If we're in an event handler, we'll run the batch at the end of it. | ||
if (inEventLoop) return; | ||
queueMicrotask(() => { | ||
const batchesToRun = batchesPending; | ||
taskPending = false; | ||
batchesPending = {}; | ||
unstable_batchedUpdates(() => Object.values(batchesToRun).forEach(setStateFn => setStateFn())); | ||
runBatch(); | ||
}); | ||
@@ -117,2 +113,6 @@ } | ||
fn.apply(ctx, args); | ||
if (taskPending) { | ||
runBatch(); | ||
} | ||
} finally { | ||
@@ -119,0 +119,0 @@ inEventLoop = false; |
{ | ||
"name": "@aha-app/react-easy-state", | ||
"version": "0.0.11-development", | ||
"version": "0.0.12-development", | ||
"description": "React state management with a minimal API. Made with ES6 Proxies.", | ||
@@ -62,3 +62,3 @@ "main": "dist/cjs.es6.js", | ||
"dependencies": { | ||
"@nx-js/observer-util": "^4.2.2" | ||
"@nx-js/observer-util": "^4.3.0-alpha.2" | ||
}, | ||
@@ -65,0 +65,0 @@ "peerDependencies": { |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
0
212521
1930
+ Added@nx-js/observer-util@4.3.0-alpha.2(transitive)
- Removed@nx-js/observer-util@4.2.2(transitive)