@preact-signals/unified-signals
Advanced tools
Comparing version
# @preact-signals/unified-signals | ||
## 0.2.6 | ||
### Patch Changes | ||
- db33dd8: Changed untrackedPolyfill implementation | ||
## 0.2.5 | ||
@@ -4,0 +10,0 @@ |
{ | ||
"name": "@preact-signals/unified-signals", | ||
"version": "0.2.5", | ||
"version": "0.2.6", | ||
"private": false, | ||
@@ -5,0 +5,0 @@ "publishConfig": { |
@@ -6,16 +6,6 @@ import * as signals from "@preact/signals-react"; | ||
let untrackedDepth = 0; | ||
const untrackedEffect = <T>(callback: () => T): T => { | ||
let isExecuted = false; | ||
const _polyfill = <T>(callback: () => T): T => { | ||
let res: T | undefined; | ||
signals.effect(() => { | ||
if (isExecuted) { | ||
return; | ||
} | ||
try { | ||
res = callback(); | ||
} finally { | ||
isExecuted = true; | ||
} | ||
signals.effect(() => () => { | ||
res = callback(); | ||
})(); | ||
@@ -26,18 +16,2 @@ | ||
export const untrackedPolyfill: Untracked = | ||
maybeUntracked ?? | ||
(<T>(callback: () => T): T => { | ||
untrackedDepth++; | ||
try { | ||
// @ts-expect-error process is not defined and bla bla bla | ||
if (process.env.NODE_ENV === "development" && untrackedDepth > 100_000) { | ||
throw new Error("untracked depth exceeded: 100_000"); | ||
} | ||
if (untrackedDepth > 1) { | ||
return callback(); | ||
} | ||
return untrackedEffect(callback); | ||
} finally { | ||
untrackedDepth--; | ||
} | ||
}); | ||
export const untrackedPolyfill: Untracked = maybeUntracked ?? _polyfill; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
2
-50%24756
-17.2%21
-4.55%385
-17.38%