Skip to content

Commit

Permalink
changes throws when given pull behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
paldepind committed Apr 12, 2019
1 parent 1feade9 commit 3cb9915
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
5 changes: 5 additions & 0 deletions src/stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,11 @@ export function changes<A>(
b: Behavior<A>,
comparator: (v: A, u: A) => boolean = (v, u) => v === u
): Stream<A> {
if (b.state === State.Pull) {
throw new Error(
"You invoked changes on a pull behavior which is not supported."
);
}
return new ChangesStream(b, comparator);
}

Expand Down
17 changes: 5 additions & 12 deletions test/stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -468,18 +468,11 @@ describe("stream", () => {
[{ a: 1, b: 0 }]
]);
});
/*
it("gives changes from pulling behavior", () => {
let x = 0;
const b = fromFunction(() => x);
const s = changes(b);
const cb = spy();
observe
x = 1;
x = 2;
x = 3;
assert.deepEqual(cb.args, [[1], [2], [3]]);
it("throws on pull behavior", () => {
const b = fromFunction(() => "hello");
assert.throws(() => {
H.changes(b);
}, /.*pull behavior.*/);
});
*/
});
});

0 comments on commit 3cb9915

Please sign in to comment.