Skip to content

Commit

Permalink
fix(signal): dont receivePrevious when listener is disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
alimd committed Mar 17, 2023
1 parent 22c0277 commit 68ae207
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions core/signal/src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ export const subscribe = <T extends Stringifyable>(
callback: listenerCallback,
};

const callbackCall = signal.detail !== undefined && options.receivePrevious !== 'No';
if (callbackCall) {
const execCallback = signal.detail !== undefined && options.receivePrevious !== 'No' && options.disabled !== true;
if (execCallback) {
// Run callback for old dispatch signal

const callback = (): void => {
Expand All @@ -148,7 +148,7 @@ export const subscribe = <T extends Stringifyable>(
}

// if once then must remove listener after fist callback called! then why push it to listenerList?!
if (!(callbackCall && options.once)) {
if (!(execCallback && options.once)) {
if (options.priority === true) {
signal.listenerList.unshift(listener);
}
Expand Down

0 comments on commit 68ae207

Please sign in to comment.