@magicx-eng/ai-autocomplete-angular 0.5.7 → 0.5.8

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.
@@ -579,16 +579,21 @@ class AIAutocompleteController {
579
579
  // handed. The core notifies listeners synchronously, and some actions
580
580
  // trigger reentrant `store.set` calls (e.g. typing a non-matching char
581
581
  // during re-edit makes the core synchronously exit re-edit and kick off a
582
- // fetch). Reentrancy makes the outer set's listener loop continue with a
583
- // now-stale snapshot, so the listener can fire *out of order* — delivering
584
- // an older state (still in re-edit) after a newer one (re-edit exited).
585
- // Reading `getState()` at emission time collapses every notification onto
586
- // the true latest state, so a stale `editingParam` can't resurrect and
587
- // retrigger the editor's re-edit caret-park (which would yank the caret
588
- // back to where re-editing started). distinctUntilChanged downstream drops
589
- // the resulting duplicate emissions. React avoids this because it batches
590
- // renders and its caret effects are dependency-gated; our subscription is
591
- // synchronous, so we coalesce here instead.
582
+ // fetch).
583
+ //
584
+ // The core's store used to deliver such a nested set inline and then
585
+ // resume the outer listener loop, so a listener could be handed an older
586
+ // state (still in re-edit) *after* a newer one (re-edit exited) — which
587
+ // resurrected a stale `editingParam` and retriggered the editor's re-edit
588
+ // caret-park, yanking the caret back to where re-editing started. The
589
+ // store now queues notifications and drains them in order, so that
590
+ // out-of-order delivery can no longer happen at the source.
591
+ //
592
+ // Reading `getState()` at emission time is kept as belt-and-braces: it
593
+ // costs nothing (distinctUntilChanged downstream drops the duplicate
594
+ // emissions) and keeps this bridge correct for any future consumer that
595
+ // emits mid-cascade. React needs neither, since it batches renders and
596
+ // gates its caret effects on dependencies.
592
597
  this.unsubscribeCore = this.core.subscribe(() => {
593
598
  if (!this.isDestroyed)
594
599
  this.rawState$.next(this.core.getState());