Skip to content

Commit

Permalink
Fixed bug
Browse files Browse the repository at this point in the history
  • Loading branch information
guillemcordoba committed Dec 19, 2023
1 parent 7840c51 commit 91487c2
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/stores/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@holochain-open-dev/stores",
"version": "0.8.8",
"version": "0.8.9",
"description": "Re-export of svelte/store, with additional utilities to build reusable holochain-open-dev modules",
"author": "[email protected]",
"main": "dist/index.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/stores/src/pipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function pipeStep<T, U>(

if (!!v && (v as Readable<any>).subscribe) {
return (v as Readable<any>).subscribe((value) => {
if ((value as AsyncStatus<U>).status) {
if (value !== undefined && (value as AsyncStatus<U>).status) {
set(value);
} else {
set({ status: "complete", value });
Expand Down
17 changes: 17 additions & 0 deletions packages/stores/tests/pipe.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,23 @@ it("pipe with normal fn that returns undefined", async () => {
});
});

it("pipe with readable fn that returns undefined", async () => {
const asyncReadableStore = asyncReadable(async (set) => {
await sleep(10);
set("hi");
});
const pipeStore = pipe(asyncReadableStore, (s) => readable(undefined));
const subscriber = pipeStore.subscribe(() => {});

expect(get(pipeStore)).to.deep.equal({ status: "pending" });
await sleep(20);

expect(get(pipeStore)).to.deep.equal({
status: "complete",
value: undefined,
});
});

it("pipe with promise", async () => {
const asyncReadableStore = asyncReadable(async (set) => {
await sleep(10);
Expand Down

0 comments on commit 91487c2

Please sign in to comment.