File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed
Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff 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 } ;
You can’t perform that action at this time.
0 commit comments