@@ -13,7 +13,7 @@ export type Updater<T> = (value: T) => T;
1313type Invalidator < T > = ( value ?: T ) => void ;
1414
1515/** Start and stop notification callbacks. */
16- export type StartStopNotifier < T > = ( set : Subscriber < T > , update ? : ( fn : Updater < T > ) => void ) => Unsubscriber | void ;
16+ export type StartStopNotifier < T > = ( set : Subscriber < T > , update : ( fn : Updater < T > ) => void ) => Unsubscriber | void ;
1717
1818/** Readable interface for subscribing. */
1919export interface Readable < T > {
@@ -115,6 +115,20 @@ type Stores = Readable<any> | [Readable<any>, ...Array<Readable<any>>] | Array<R
115115type StoresValues < T > = T extends Readable < infer U > ? U :
116116 { [ K in keyof T ] : T [ K ] extends Readable < infer U > ? U : never } ;
117117
118+ /**
119+ * Derived value store by synchronizing one or more readable stores and
120+ * applying an aggregation function over its input values.
121+ *
122+ * @param stores - input stores
123+ * @param fn - function callback that aggregates the values
124+ * @param initial_value - when used asynchronously
125+ */
126+ export function derived < S extends Stores , T > (
127+ stores : S ,
128+ fn : ( values : StoresValues < S > , set : Subscriber < T > , update : ( fn : Updater < T > ) => void ) => Unsubscriber | void ,
129+ initial_value ?: T
130+ ) : Readable < T > ;
131+
118132/**
119133 * Derived value store by synchronizing one or more readable stores and
120134 * applying an aggregation function over its input values.
@@ -125,7 +139,7 @@ type StoresValues<T> = T extends Readable<infer U> ? U :
125139 */
126140export function derived < S extends Stores , T > (
127141 stores : S ,
128- fn : ( values : StoresValues < S > , set : Subscriber < T > , update ?: ( fn : Updater < T > ) => void ) => Unsubscriber | void ,
142+ fn : ( values : StoresValues < S > , set : Subscriber < T > ) => Unsubscriber | void ,
129143 initial_value ?: T
130144) : Readable < T > ;
131145
0 commit comments