From 8fafcc6701c681578de291a5e37ee3c1af152eac Mon Sep 17 00:00:00 2001 From: David de Kloet Date: Wed, 1 Feb 2023 22:22:57 +0100 Subject: [PATCH 1/2] In createDerivedStore, instead create a new store which simply doesn't expose `set` and `update`. --- frontend/src/lib/derived/debug.derived.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/frontend/src/lib/derived/debug.derived.ts b/frontend/src/lib/derived/debug.derived.ts index 092b3e1ce17..1c8f94eda7d 100644 --- a/frontend/src/lib/derived/debug.derived.ts +++ b/frontend/src/lib/derived/debug.derived.ts @@ -31,8 +31,9 @@ import { type Writable, } from "svelte/store"; +// TODO(dskloetd): Rename to createReadableStore. const createDerivedStore = (store: Writable): Readable => - derived(store, (store) => store); + { subscribe: store.subscribe }; let addAccountStore: Readable; export const debugAddAccountStore = (store: Writable) => From 0afb9d5d490315721681d01f91db8b418310cd40 Mon Sep 17 00:00:00 2001 From: David de Kloet Date: Thu, 2 Feb 2023 08:06:50 +0100 Subject: [PATCH 2/2] fmt and rename --- frontend/src/lib/derived/debug.derived.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/frontend/src/lib/derived/debug.derived.ts b/frontend/src/lib/derived/debug.derived.ts index 1c8f94eda7d..c27a27e4a50 100644 --- a/frontend/src/lib/derived/debug.derived.ts +++ b/frontend/src/lib/derived/debug.derived.ts @@ -31,13 +31,13 @@ import { type Writable, } from "svelte/store"; -// TODO(dskloetd): Rename to createReadableStore. -const createDerivedStore = (store: Writable): Readable => - { subscribe: store.subscribe }; +const createReadableStore = (store: Writable): Readable => ({ + subscribe: store.subscribe, +}); let addAccountStore: Readable; export const debugAddAccountStore = (store: Writable) => - (addAccountStore = createDerivedStore(store)); + (addAccountStore = createReadableStore(store)); // Context stores might not be initialized when debugger is called. // Therefore, we need to initialize them here. @@ -46,14 +46,14 @@ let walletStore: Readable = readable({ neurons: [], }); export const debugSelectedAccountStore = (store: Writable) => - (walletStore = createDerivedStore(store)); + (walletStore = createReadableStore(store)); let selectedProposalStore: Readable = readable({ proposalId: undefined, proposal: undefined, }); export const debugSelectedProposalStore = ( store: Writable -) => (selectedProposalStore = createDerivedStore(store)); +) => (selectedProposalStore = createReadableStore(store)); let selectedCanisterStore: Readable = readable({ info: undefined, details: undefined, @@ -63,21 +63,21 @@ let selectedCanisterStore: Readable = readable({ }); export const debugSelectedCanisterStore = ( store: Writable -) => (selectedCanisterStore = createDerivedStore(store)); +) => (selectedCanisterStore = createReadableStore(store)); let selectedProjectStore: Readable = readable({ summary: null, swapCommitment: null, }); export const debugSelectedProjectStore = ( store: Writable -) => (selectedProjectStore = createDerivedStore(store)); +) => (selectedProjectStore = createReadableStore(store)); let selectedSnsNeuronStore: Readable = readable({ selected: undefined, neuron: undefined, }); export const debugSelectedSnsNeuronStore = ( store: Writable -) => (selectedSnsNeuronStore = createDerivedStore(store)); +) => (selectedSnsNeuronStore = createReadableStore(store)); const transactionsStore = writable(undefined); export const debugTransactions = (transactions: Transaction[] | undefined) => { transactionsStore.set(transactions);