Skip to content

Commit

Permalink
chore: update mutation tracker logic
Browse files Browse the repository at this point in the history
  • Loading branch information
jmsjtu committed Jan 30, 2024
1 parent 0a08b45 commit 66f885b
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions packages/@lwc/engine-core/src/libs/mutation-tracker/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,25 +70,21 @@ export type JobFunction = () => void;
export class ReactiveObserver {
private listeners: (ObservedMemberPropertyRecords | CallbackFunction)[] = [];
private callback: CallbackFunction;
private isActive: boolean;

constructor(callback: CallbackFunction) {
this.callback = callback;
this.isActive = false;
}

observe(job: JobFunction) {
const inceptionReactiveRecord = currentReactiveObserver;
currentReactiveObserver = this;
this.isActive = true;
let error;
try {
job();
} catch (e) {
error = Object(e);
} finally {
currentReactiveObserver = inceptionReactiveRecord;
this.isActive = false;
if (error !== undefined) {
throw error; // eslint-disable-line no-unsafe-finally
}
Expand Down Expand Up @@ -144,6 +140,6 @@ export class ReactiveObserver {
}

isObserving() {
return this.isActive;
return currentReactiveObserver === this;
}
}

0 comments on commit 66f885b

Please sign in to comment.