diff --git a/src/behavior.ts b/src/behavior.ts index d790572..99fc079 100644 --- a/src/behavior.ts +++ b/src/behavior.ts @@ -69,7 +69,7 @@ export abstract class Behavior extends Reactive } abstract update(t: number): A; pushB(t: number): void { - if (this.pulledAt !== t) { + if (this.state !== State.Inactive && this.pulledAt !== t) { this.pull(t); if (this.changedAt === t && this.state === State.Push) { pushToChildren(t, this); diff --git a/test/placeholder.ts b/test/placeholder.ts index 7b7767f..62fd0a9 100644 --- a/test/placeholder.ts +++ b/test/placeholder.ts @@ -241,6 +241,26 @@ describe("placeholder", () => { p.replaceWith(H.Behavior.of(3)); assert.strictEqual(H.at(b3), 16); }); + it("handles behavior depending on two placeholder", () => { + // p1 p2 + // \ / + // b3 + const p1 = H.placeholder(); + const p2 = H.placeholder(); + const b3 = H.lift( + (n, m) => { + assert.isNumber(n); + assert.isNumber(m); + return n + m; + }, + p1 as Behavior, + p2 + ); + subscribeSpy(b3); + p1.replaceWith(H.Behavior.of(3)); + p2.replaceWith(H.Behavior.of(2)); + assert.strictEqual(H.at(b3), 5); //12); + }); }); describe("stream", () => { it("is stream", () => {