Merge branch 'develop' into kegan/lists-as-keys
This commit is contained in:
commit
6ec25234d7
22 changed files with 127 additions and 77 deletions
|
@ -63,6 +63,9 @@ export function useEventEmitter(emitter: EventEmitter | undefined, eventName: st
|
|||
|
||||
type Mapper<T> = (...args: any[]) => T;
|
||||
|
||||
/**
|
||||
* {@link useEventEmitterState}
|
||||
*/
|
||||
export function useTypedEventEmitterState<T, Events extends string, Arguments extends ListenerMap<Events>>(
|
||||
emitter: TypedEventEmitter<Events, Arguments>,
|
||||
eventName: Events,
|
||||
|
@ -71,6 +74,16 @@ export function useTypedEventEmitterState<T, Events extends string, Arguments ex
|
|||
return useEventEmitterState<T>(emitter, eventName, fn);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a state, that can be updated by events.
|
||||
*
|
||||
* @param emitter The emitter sending the event
|
||||
* @param eventName Event name to listen for
|
||||
* @param fn The callback function, that should return the state value.
|
||||
* It should have the signature of the event callback, except that all parameters are optional.
|
||||
* If the params are not set, a default value for the state should be returned.
|
||||
* @returns State
|
||||
*/
|
||||
export function useEventEmitterState<T>(
|
||||
emitter: EventEmitter | undefined,
|
||||
eventName: string | symbol,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue