Skip to content

v0.1.3

Compare
Choose a tag to compare
@efstajas efstajas released this 21 Mar 11:34
· 5 commits to main since this release
fa7f78d

New feature:

Setting a custom writable type

If you want to use a custom TypeScript type for the storedWritable, you can pass an optional type parameter. When setting a type parameter,
your schema parameter must match the supplied type.

import storedWritable from '@efstajas/svelte-stored-writable';
import { z } from 'zod';

interface MyWritableType {
  foo: string;
  bar: number;
}

const myWritableSchema = z.object({
  foo: z.string(),
  bar: z.number(),
});

// myStoredWritable is typed as Writable<MyWritableType>. `myWritableSchema` must match `MyWritableType`.
const myStoredWritable = storedWritable<MyWritableType>('my-writable-key', myWritableSchema, { foo: 'hello', bar: 1234 });

Full Changelog: v0.1.1...v0.1.2