nanostores / nanostores

A tiny (286 bytes) state manager for React/RN/Preact/Vue/Svelte with many atomic tree-shakable stores
MIT License
5.41k stars 109 forks source link

`cleanStores` doesn't reset values of `computed` #323

Open martinmckenna opened 4 months ago

martinmckenna commented 4 months ago

Hi

I noticed that when using

afterEach(() => {
  cleanStores()
})

in my tests, all values wrapped in computed() are not reset

Example code:

export const $getThings = createFetcherStore(
  ['project', 'memberships', $projectId],
  {
    fetcher: () =>
      getThings().then((response) => response.data),
  },
);

export const $getProjectMembershipsWithSSHKeys = computed(
  [$getThings],
  (data) => ({
    ...data,
    data: data.data?.memberships.filter(someFilterFn)
  }),
);
ai commented 4 months ago

You need to pass stores to the function cleanStores(store1, store2).

Can you show expected and actual examples?