Skip to content

Commit a7e2a61

Browse files
committed
StartStopNotifier type now requires update param
This will be a breaking change for anyone who uses the StartStopNotifier type in their custom stores.
1 parent b2b7bd1 commit a7e2a61

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

src/runtime/store/index.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export type Updater<T> = (value: T) => T;
1313
type 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. */
1919
export interface Readable<T> {
@@ -115,6 +115,20 @@ type Stores = Readable<any> | [Readable<any>, ...Array<Readable<any>>] | Array<R
115115
type 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
*/
126140
export 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

Comments
 (0)