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

quarx

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

quarx - npm Package Compare versions

Comparing version 5.2.1 to 5.2.2

2

package.json
{
"name": "quarx",
"version": "5.2.1",
"version": "5.2.2",
"description": "Simple tiny reactivity engine",

@@ -5,0 +5,0 @@ "type": "module",

@@ -1,2 +0,2 @@

import { autorun, createAtom, untrack } from './core.js';
import { autorun, createAtom } from './core.js';

@@ -28,4 +28,2 @@ export function subscribable(evaluate, options = {}) {

subscribe = untrack(subscribe);
let result, error;

@@ -32,0 +30,0 @@

@@ -40,20 +40,16 @@ const TAG = '@dmaevsky/quarx';

const observers = new Map();
let dispose, actualize;
let dispose, pullUpstream;
return {
reportObserved() {
Quarx.debug(`[Quarx]: ${name} observed`);
const { invalidate, link } = Quarx.stack[Quarx.stack.length - 1] || {};
Quarx.debug(`[Quarx]: ${name} observed -> ${!!invalidate}`);
if (!invalidate) return false;
if (!observers.size) {
if (dispose && Quarx.pendingDispose.has(dispose)) {
Quarx.pendingDispose.delete(dispose);
}
else if (onBecomeObserved) {
const cleanup = onBecomeObserved();
dispose = tryCatch(() => cleanup && cleanup(), onError);
}
}
const unobserved = !observers.size;
// Important to add the new observer before calling onBecomeObserved, because the latter may call reportChanged
// as is the case with `toObservable` implementation
if (!observers.has(invalidate)) {

@@ -66,3 +62,3 @@ observers.set(invalidate, {

actualize() {
if (actualize) actualize();
if (pullUpstream) pullUpstream();
}

@@ -74,3 +70,13 @@ });

if (actualize) actualize();
if (unobserved) {
if (dispose && Quarx.pendingDispose.has(dispose)) {
Quarx.pendingDispose.delete(dispose);
}
else if (onBecomeObserved) {
const cleanup = onBecomeObserved();
dispose = tryCatch(() => cleanup && cleanup(), onError);
}
}
if (pullUpstream) pullUpstream();
return true;

@@ -81,5 +87,10 @@ },

Quarx.debug(`[Quarx]: ${name} changed`);
({ actualize } = Quarx.stack[Quarx.stack.length - 1] || {});
const { invalidate, actualize } = Quarx.stack[Quarx.stack.length - 1] || {};
// Prevent creating self-reference for the running computation
if (!observers.has(invalidate)) {
pullUpstream = actualize;
}
for (let invalidate of observers.keys()) invalidate();
hydrate();

@@ -104,9 +115,16 @@ }

function invalidate() {
Quarx.debug(`[Quarx]: invalidating ${name}:`, seqNo, Quarx.sequenceNumber);
if (Quarx.cleaningUp) {
// No invalidations allowed in dispose callbacks
return Quarx.error(`[Quarx]: prevent invalidating ${name} while running the dispose queue`);
const message = `[Quarx]: attempt to invalidate ${name} while running the dispose queue`;
Quarx.debug(message);
return onError(new Error(message));
}
if (Quarx.hydrating && seqNo === Quarx.sequenceNumber) {
// Invalidating a freshly hydrated computation == cycle, but cannot throw here yet, because we don't have the stack to report
return Quarx.error(`[Quarx]: prevent invalidating ${name}: cycle detected`);
Quarx.debug(`[Quarx]: Invalidating a freshly hydrated computation ${name} from ${Quarx.stack[0].name} === cycle`);
// Calling run greadily so that it can report the cycle
return run();
}

@@ -119,2 +137,4 @@

function actualize() {
Quarx.debug(`[Quarx]: Actualizing ${name}`, seqNo, Quarx.sequenceNumber);
if (isRunning) {

@@ -126,2 +146,3 @@ const trace = [...Quarx.stack.map(({ name }) => name), name];

}
if (seqNo === Quarx.sequenceNumber) return;

@@ -128,0 +149,0 @@ if (!seqNo) return run();

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