From e11b31c29dfb0f0c7a3da66f42056a954f55dbf5 Mon Sep 17 00:00:00 2001 From: Henrik Giesel Date: Sun, 21 Mar 2021 21:38:23 +0100 Subject: [PATCH] Rename asyncRefresh to asyncReactive --- ts/graphs/async.ts | 2 +- ts/graphs/{asyncRefresh.ts => asyncReactive.ts} | 10 ++++------ 2 files changed, 5 insertions(+), 7 deletions(-) rename ts/graphs/{asyncRefresh.ts => asyncReactive.ts} (86%) diff --git a/ts/graphs/async.ts b/ts/graphs/async.ts index 5ce71974f..8037a7e24 100644 --- a/ts/graphs/async.ts +++ b/ts/graphs/async.ts @@ -1,6 +1,6 @@ import { Readable, readable, derived } from "svelte/store"; -export interface AsyncData { +interface AsyncData { value: Readable; error: Readable; pending: Readable; diff --git a/ts/graphs/asyncRefresh.ts b/ts/graphs/asyncReactive.ts similarity index 86% rename from ts/graphs/asyncRefresh.ts rename to ts/graphs/asyncReactive.ts index 660eacfd1..5016c7227 100644 --- a/ts/graphs/asyncRefresh.ts +++ b/ts/graphs/asyncReactive.ts @@ -1,6 +1,6 @@ import { Readable, readable, derived } from "svelte/store"; -interface AsyncRefreshData { +interface AsyncReativeData { value: Readable; error: Readable; pending: Readable; @@ -8,10 +8,10 @@ interface AsyncRefreshData { loading: Readable; } -function useAsyncRefresh( +function useAsyncReactive( asyncFunction: () => Promise, dependencies: [Readable, ...Readable[]] -): AsyncRefreshData { +): AsyncReativeData { const initial = asyncFunction(); const promise = derived(dependencies, (_, set) => set(asyncFunction()), initial); @@ -19,7 +19,6 @@ function useAsyncRefresh( promise, ($promise, set: (value: T | null) => void) => { $promise.then((value: T) => set(value)); - return () => set(null); }, null ); @@ -28,7 +27,6 @@ function useAsyncRefresh( promise, ($promise, set: (error: E | null) => void) => { $promise.catch((error: E) => set(error)); - return () => set(null); }, null ); @@ -58,4 +56,4 @@ function useAsyncRefresh( return { value, error, pending, loading, success }; } -export default useAsyncRefresh; +export default useAsyncReactive;