import { Observable } from 'rxjs'; import { ActionCreatorWithPayload, ActionCreatorWithoutPayload } from './ActionCreator'; import { UnknownAction } from '../internal/types'; import { ObservableState } from '../observableState'; export type ActionStream = Observable; export type ActionDispatcher = (action: UnknownAction, namespace?: string) => void; /** * Helper type for extracting the payload type from an action creator * * ``` * type Payload = ExtractPayload; * ``` */ export type ExtractPayload> = ReturnType['payload']; /** * Type helper to infer the payload of an action creator. * This should be preferred over exporting the types separately. */ export type InferPayloadFromActionCreator = TActionCreator extends ActionCreatorWithPayload ? TValueType : TActionCreator extends ActionCreatorWithoutPayload ? void : never; /** * The equivalent of TypeScript's built-in `Awaited` but for observables. * Infer the type of the value wrapped inside an Observable. */ export type Observed = TObservable extends Observable ? TValueType : TObservable extends ObservableState ? TValueType : never;