diff --git a/src/stream.ts b/src/stream.ts index 5f7dd52..8f3bfd8 100644 --- a/src/stream.ts +++ b/src/stream.ts @@ -276,6 +276,11 @@ export function changes( b: Behavior, comparator: (v: A, u: A) => boolean = (v, u) => v === u ): Stream { + if (b.state === State.Pull) { + throw new Error( + "You invoked changes on a pull behavior which is not supported." + ); + } return new ChangesStream(b, comparator); } diff --git a/test/stream.ts b/test/stream.ts index df00507..f525e13 100644 --- a/test/stream.ts +++ b/test/stream.ts @@ -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.*/); }); - */ }); });