From ce6c0bb186323f38bea102ac314b0040a1e2fa91 Mon Sep 17 00:00:00 2001 From: PS Date: Fri, 10 Jan 2025 14:24:14 +0100 Subject: [PATCH] Fixed order of dispatcher listeners (all listeners are called before specific listeners) --- .changeset/eighty-eyes-smash.md | 5 +++++ packages/core/src/event/DispatcherImpl.ts | 8 ++++---- packages/core/src/index.ts | 2 ++ 3 files changed, 11 insertions(+), 4 deletions(-) create mode 100644 .changeset/eighty-eyes-smash.md diff --git a/.changeset/eighty-eyes-smash.md b/.changeset/eighty-eyes-smash.md new file mode 100644 index 0000000000..1be4778c78 --- /dev/null +++ b/.changeset/eighty-eyes-smash.md @@ -0,0 +1,5 @@ +--- +"@ima/core": patch +--- + +Fixed order of dispatcher listeners (all listeners are called before specific listeners) diff --git a/packages/core/src/event/DispatcherImpl.ts b/packages/core/src/event/DispatcherImpl.ts index d231bfec4c..f70210df41 100644 --- a/packages/core/src/event/DispatcherImpl.ts +++ b/packages/core/src/event/DispatcherImpl.ts @@ -187,15 +187,15 @@ export class DispatcherImpl extends Dispatcher { ): this { const listeners = this._getListenersOf(event); - for (const [listener, scopes] of listeners) { + for (const [listener, scopes] of this._eventListenersAll.entries()) { for (const scope of scopes) { - listener.bind(scope)(data); + listener.bind(scope)(event, data); } } - for (const [listener, scopes] of this._eventListenersAll.entries()) { + for (const [listener, scopes] of listeners) { for (const scope of scopes) { - listener.bind(scope)(event, data); + listener.bind(scope)(data); } } diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index 7bcfda32e5..58c135180d 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -39,6 +39,8 @@ export { type DispatcherEventsMap, } from './event/Dispatcher'; export { DispatcherImpl } from './event/DispatcherImpl'; +export { Observable } from './event/Observable'; +export { ObservableImpl } from './event/ObservableImpl'; export { EventBus, type EventBusEventHandler,