Skip to content

Commit b168657

Browse files
committed
Switching storage to readable store
1 parent beeb5dd commit b168657

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/lib/stores/storage.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { writable } from "svelte/store";
1+
import { readable } from "svelte/store";
22
import { getDownloadURL, list, ref } from "firebase/storage";
33

44
import type {
@@ -31,7 +31,7 @@ export function storageListStore(
3131

3232
// Fallback for SSR
3333
if (!globalThis.window) {
34-
const { subscribe } = writable(startWith);
34+
const { subscribe } = readable(startWith);
3535
return {
3636
subscribe,
3737
reference: null,
@@ -43,7 +43,7 @@ export function storageListStore(
4343
console.warn(
4444
"Cloud Storage is not initialized. Are you missing FirebaseApp as a parent component?"
4545
);
46-
const { subscribe } = writable(defaultListResult);
46+
const { subscribe } = readable(defaultListResult);
4747
return {
4848
subscribe,
4949
reference: null,
@@ -52,7 +52,7 @@ export function storageListStore(
5252

5353
const storageRef = typeof reference === "string" ? ref(storage, reference) : reference;
5454

55-
const { subscribe } = writable(startWith, (set) => {
55+
const { subscribe } = readable(startWith, (set) => {
5656
list(storageRef).then((snapshot) => {
5757
set(snapshot);
5858
});
@@ -83,7 +83,7 @@ export function downloadUrlStore(
8383

8484
// Fallback for SSR
8585
if (!globalThis.window) {
86-
const { subscribe } = writable(startWith);
86+
const { subscribe } = readable(startWith);
8787
return {
8888
subscribe,
8989
reference: null,
@@ -95,7 +95,7 @@ export function downloadUrlStore(
9595
console.warn(
9696
"Cloud Storage is not initialized. Are you missing FirebaseApp as a parent component?"
9797
);
98-
const { subscribe } = writable(null);
98+
const { subscribe } = readable(null);
9999
return {
100100
subscribe,
101101
reference: null,
@@ -104,7 +104,7 @@ export function downloadUrlStore(
104104

105105
const storageRef = typeof reference === "string" ? ref(storage, reference) : reference;
106106

107-
const { subscribe } = writable(startWith, (set) => {
107+
const { subscribe } = readable(startWith, (set) => {
108108
getDownloadURL(storageRef).then((snapshot) => {
109109
set(snapshot);
110110
});

0 commit comments

Comments
 (0)