joshnuss / svelte-persisted-store

A Svelte store that persists to localStorage

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

No derived function?

quinncomendant opened this issue · comments

It appears that svelte-local-storage-store doesn't come with a derived() function? Is it okay to use sveltekit's derived function with svelte-local-storage-store?

import { writable } from 'svelte-local-storage-store';
import { derived } from 'svelte/store';

export const jobs = writable('jobs', []);
export const remoteOnly = writable('remoteOnly', false);

export const filteredJobs = derived(
  [jobs, remoteOnly],
  ([$jobs, $remoteOnly]) => {
    return filterByRemote($jobs, $remoteOnly)
  }
);

This seems to be working (maybe? having seen any errors yet.). I just want to confirm that they are compatible. Thanks for this awesome module!

Thanks @quinncomendant,

You are totally correct, it works with the standard derived() function. Basically anything that conforms to the Store interface is accepted by derived()

All the best,
Josh

Awesome, thanks for the reply. 🥰