Skip to content

Commit

Permalink
Refactors
Browse files Browse the repository at this point in the history
  • Loading branch information
JoviDeCroock committed Dec 27, 2024
1 parent 438a6f4 commit ee34c3c
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -301,15 +301,16 @@ Signal.prototype._refresh = function () {
};

Signal.prototype._subscribe = function (node) {
if (this._watched != null && this._targets === undefined) {
this._watched();
}
if (this._targets !== node && node._prevTarget === undefined) {
node._nextTarget = this._targets;
if (this._targets !== undefined) {
this._targets._prevTarget = node;
}
const targets = this._targets;
if (targets !== node && node._prevTarget === undefined) {
node._nextTarget = targets;
this._targets = node;

if (targets !== undefined) {
targets._prevTarget = node;
} else if (this._watched !== undefined) {
this._watched();
}
}
};

Expand All @@ -330,10 +331,9 @@ Signal.prototype._unsubscribe = function (node) {

if (node === this._targets) {
this._targets = next;
}

if (this._unwatched != null && this._targets === undefined) {
this._unwatched();
if (next === undefined && this._unwatched !== undefined) {
this._unwatched();
}
}
}
};
Expand Down

0 comments on commit ee34c3c

Please sign in to comment.