Open-Source API Development Ecosystem • https://hoppscotch.io • Offline, On-Prem & Cloud • Web, Desktop & CLI • Open-Source Alternative to Postman, Insomnia
TypeScript apiapi-clientapi-restapi-testingdeveloper-toolsgraphqlhttphttp-clientpwarestrest-apispatestingtesting-toolstoolsvuevuejswebsocket
chore: improve DispatchingStore typings for dispatch streams
Andrew Bastin2545262fc2b1
diff --git a/packages/hoppscotch-common/src/newstore/DispatchingStore.ts b/packages/hoppscotch-common/src/newstore/DispatchingStore.tsindex c6c71d788..a54b692c8 100644--- a/packages/hoppscotch-common/src/newstore/DispatchingStore.ts+++ b/packages/hoppscotch-common/src/newstore/DispatchingStore.ts@@ -23,12 +23,13 @@ export const defineDispatchers = <type Dispatch<StoreType,- DispatchersType extends { [x: string]: DispatcherFunc<StoreType, any> },- Dispatcher extends keyof DispatchersType+ DispatchersType extends { [x: string]: DispatcherFunc<StoreType, any> }> = {- dispatcher: Dispatcher- payload: Parameters<DispatchersType[Dispatcher]>[1]-}+ [Dispatcher in keyof DispatchersType]: {+ dispatcher: Dispatcher+ payload: Parameters<DispatchersType[Dispatcher]>[1]+ }+}[keyof DispatchersType]export default class DispatchingStore<StoreType,@@ -36,9 +37,7 @@ export default class DispatchingStore<> {#state$: BehaviorSubject<StoreType>#dispatchers: DispatchersType- #dispatches$: Subject<- Dispatch<StoreType, DispatchersType, keyof DispatchersType>- > = new Subject()+ #dispatches$: Subject<Dispatch<StoreType, DispatchersType>> = new Subject()constructor(initialValue: StoreType, dispatchers: DispatchersType) {this.#state$ = new BehaviorSubject(initialValue)@@ -70,10 +69,7 @@ export default class DispatchingStore<return this.#dispatches$}- dispatch<Dispatcher extends keyof DispatchersType>({- dispatcher,- payload,- }: Dispatch<StoreType, DispatchersType, Dispatcher>) {+ dispatch({ dispatcher, payload }: Dispatch<StoreType, DispatchersType>) {if (!this.#dispatchers[dispatcher])throw new Error(`Undefined dispatch type '${String(dispatcher)}'`)