Skip to content

Commit e55c763

Browse files
committed
Fixed docs for svelte/store not being rendered
1 parent 999b92d commit e55c763

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

packages/svelte/types/index.d.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2148,10 +2148,42 @@ declare module 'svelte/store' {
21482148
*/
21492149
update(this: void, updater: Updater<T>): void;
21502150
}
2151+
2152+
/**
2153+
* Create a store from a function that returns state, and (to make a writable store), an
2154+
* optional second function that sets state.
2155+
*
2156+
* ```ts
2157+
* import { toStore } from 'svelte/store';
2158+
*
2159+
* let count = $state(0);
2160+
*
2161+
* const store = toStore(() => count, (v) => (count = v));
2162+
* ```
2163+
*/
21512164
export function toStore<V>(get: () => V, set: (v: V) => void): Writable<V>;
21522165

21532166
export function toStore<V>(get: () => V): Readable<V>;
21542167

2168+
/**
2169+
* Convert a store to an object with a reactive `current` property. If `store`
2170+
* is a readable store, `current` will be a readonly property.
2171+
*
2172+
* ```ts
2173+
* import { fromStore, get, writable } from 'svelte/store';
2174+
*
2175+
* const store = writable(0);
2176+
*
2177+
* const count = fromStore(store);
2178+
*
2179+
* count.current; // 0;
2180+
* store.set(1);
2181+
* count.current; // 1
2182+
*
2183+
* count.current += 1;
2184+
* get(store); // 2
2185+
* ```
2186+
*/
21552187
export function fromStore<V>(store: Writable<V>): {
21562188
current: V;
21572189
};

0 commit comments

Comments
 (0)