diff --git a/src/runtime/internal/utils.ts b/src/runtime/internal/utils.ts index c7722e1a07..4ba7e18c15 100644 --- a/src/runtime/internal/utils.ts +++ b/src/runtime/internal/utils.ts @@ -43,12 +43,15 @@ export function not_equal(a, b) { } export function validate_store(store, name) { - if (!store || typeof store.subscribe !== 'function') { + if (store != null && typeof store.subscribe !== 'function') { throw new Error(`'${name}' is not a store with a 'subscribe' method`); } } export function subscribe(store, ...callbacks) { + if (store == null) { + return noop; + } const unsub = store.subscribe(...callbacks); return unsub.unsubscribe ? () => unsub.unsubscribe() : unsub; }