@mantaq/core 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.mjs +5 -6
  2. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -383,8 +383,8 @@ var Actor = class {
383
383
  clock;
384
384
  #context;
385
385
  #contextHandle;
386
+ #contextWritten = false;
386
387
  #lastState;
387
- #lastContext;
388
388
  #options;
389
389
  #regions = {};
390
390
  #children = /* @__PURE__ */ new Map();
@@ -435,9 +435,9 @@ var Actor = class {
435
435
  this.state = initState;
436
436
  this.#context = options.context ?? {};
437
437
  this.#lastState = initState;
438
- this.#lastContext = this.#context;
439
438
  this.#contextHandle = new Context(() => this.#context, (value) => {
440
439
  this.#context = value;
440
+ this.#contextWritten = true;
441
441
  });
442
442
  this.#subs.seed(this.snapshot());
443
443
  if (options.regions) for (const [key, child] of Object.entries(options.regions)) {
@@ -466,9 +466,9 @@ var Actor = class {
466
466
  this.#emitChangeIfDirty();
467
467
  }
468
468
  #emitChangeIfDirty() {
469
- if (this.state === this.#lastState && this.#context === this.#lastContext) return;
469
+ if (this.state === this.#lastState && !this.#contextWritten) return;
470
470
  this.#lastState = this.state;
471
- this.#lastContext = this.#context;
471
+ this.#contextWritten = false;
472
472
  this.#subs.emitChange(this.snapshot());
473
473
  }
474
474
  #dispatch(event) {
@@ -557,8 +557,7 @@ var Actor = class {
557
557
  return false;
558
558
  }
559
559
  count++;
560
- if (this.#internalIds.has(event.id)) this.#dispatch(event);
561
- else if (this.#inputIds.has(event.id)) this.#dispatch(event);
560
+ if (this.#internalIds.has(event.id) || this.#inputIds.has(event.id)) this.#dispatch(event);
562
561
  else if (this.#outputHandler) this.#outputHandler(event);
563
562
  return true;
564
563
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mantaq/core",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "State machine runtime with actor model, event system, state hierarchy, effects, and virtual clock.",
5
5
  "license": "MIT",
6
6
  "repository": {