Comparing version 5.3.0 to 5.4.0
{ | ||
"name": "quarx", | ||
"version": "5.3.0", | ||
"version": "5.4.0", | ||
"description": "Simple tiny reactivity engine", | ||
@@ -5,0 +5,0 @@ "type": "module", |
@@ -16,4 +16,6 @@ import { autorun, createAtom } from './core.js'; | ||
let result, error; | ||
const off = subscribe(value => result = value, e => error = e, e => error = e); | ||
off(); | ||
const off = subscribe(value => {result = value}, e => {error = e}, e => {error = e}); | ||
if (off) off(); | ||
if (error) throw error; | ||
@@ -29,3 +31,3 @@ return result; | ||
let result, error; | ||
let result, error, subscribed = false; | ||
@@ -40,7 +42,18 @@ function set(e, r) { | ||
const atom = createAtom(() => subscribe(r => set(null, r), set, set), { name }); | ||
function start() { | ||
const off = subscribe(r => set(null, r), set, set); | ||
subscribed = true; | ||
return () => { | ||
if (off) off(); | ||
subscribed = false; | ||
} | ||
} | ||
const atom = createAtom(start, { name }); | ||
return { | ||
get() { | ||
if (!atom.reportObserved()) { | ||
atom.reportObserved(); | ||
if (!subscribed) { | ||
return get({ subscribe }); | ||
@@ -47,0 +60,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
21336
392