Skip to content

Commit

Permalink
push on behavior stops at pull behaviors
Browse files Browse the repository at this point in the history
  • Loading branch information
paldepind committed Sep 15, 2019
1 parent 1cad54b commit 771977c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/behavior.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export abstract class Behavior<A> extends Reactive<A, BListener>
}
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);
Expand Down
20 changes: 20 additions & 0 deletions test/placeholder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<number>();
const p2 = H.placeholder<number>();
const b3 = H.lift(
(n, m) => {
assert.isNumber(n);
assert.isNumber(m);
return n + m;
},
p1 as Behavior<number>,
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", () => {
Expand Down

0 comments on commit 771977c

Please sign in to comment.