mst-effect
Advanced tools
Comparing version 1.2.1-alpha.1 to 1.2.1-alpha.2
import { Observable } from 'rxjs'; | ||
import type { PayloadFunc, AnyInstance } from '../types'; | ||
import type { PayloadFunc, AnyInstance, NormalizeOptionalPayload } from '../types'; | ||
import type { ValidEffectActions } from './action'; | ||
export declare type EffectFactory<P> = (payload$: Observable<P>) => Observable<ValidEffectActions>; | ||
export declare type EffectFactory<P> = (payload$: Observable<NormalizeOptionalPayload<P>>) => Observable<ValidEffectActions>; | ||
export declare type EffectDispatcher<P> = PayloadFunc<P, void>; | ||
export declare function effect<P>(self: AnyInstance, factory: EffectFactory<P>): EffectDispatcher<P>; | ||
//# sourceMappingURL=effect.d.ts.map |
@@ -6,4 +6,5 @@ import type { IAnyModelType, Instance } from 'mobx-state-tree'; | ||
export declare type IsOptionalPayload<Payload> = undefined extends Payload ? true : void extends Payload ? true : false; | ||
export declare type PayloadFunc<Payload, ReturnType> = IsEmptyPayload<Payload> extends true ? () => ReturnType : IsOptionalPayload<Payload> extends true ? (payload?: Exclude<Payload, undefined | void>) => ReturnType : (payload: Payload) => ReturnType; | ||
export declare type NormalizeOptionalPayload<Payload> = IsOptionalPayload<Payload> extends true ? Exclude<Payload, void> | undefined : Payload; | ||
export declare type PayloadFunc<Payload, ReturnType> = IsEmptyPayload<Payload> extends true ? () => ReturnType : IsOptionalPayload<Payload> extends true ? (payload?: NormalizeOptionalPayload<Payload>) => ReturnType : (payload: Payload) => ReturnType; | ||
export declare type AnyInstance = Instance<IAnyModelType>; | ||
//# sourceMappingURL=types.d.ts.map |
import { Observable } from 'rxjs'; | ||
import type { PayloadFunc, AnyInstance } from '../types'; | ||
import type { PayloadFunc, AnyInstance, NormalizeOptionalPayload } from '../types'; | ||
import type { ValidEffectActions } from './action'; | ||
export declare type EffectFactory<P> = (payload$: Observable<P>) => Observable<ValidEffectActions>; | ||
export declare type EffectFactory<P> = (payload$: Observable<NormalizeOptionalPayload<P>>) => Observable<ValidEffectActions>; | ||
export declare type EffectDispatcher<P> = PayloadFunc<P, void>; | ||
export declare function effect<P>(self: AnyInstance, factory: EffectFactory<P>): EffectDispatcher<P>; | ||
//# sourceMappingURL=effect.d.ts.map |
@@ -6,4 +6,5 @@ import type { IAnyModelType, Instance } from 'mobx-state-tree'; | ||
export declare type IsOptionalPayload<Payload> = undefined extends Payload ? true : void extends Payload ? true : false; | ||
export declare type PayloadFunc<Payload, ReturnType> = IsEmptyPayload<Payload> extends true ? () => ReturnType : IsOptionalPayload<Payload> extends true ? (payload?: Exclude<Payload, undefined | void>) => ReturnType : (payload: Payload) => ReturnType; | ||
export declare type NormalizeOptionalPayload<Payload> = IsOptionalPayload<Payload> extends true ? Exclude<Payload, void> | undefined : Payload; | ||
export declare type PayloadFunc<Payload, ReturnType> = IsEmptyPayload<Payload> extends true ? () => ReturnType : IsOptionalPayload<Payload> extends true ? (payload?: NormalizeOptionalPayload<Payload>) => ReturnType : (payload: Payload) => ReturnType; | ||
export declare type AnyInstance = Instance<IAnyModelType>; | ||
//# sourceMappingURL=types.d.ts.map |
{ | ||
"name": "mst-effect", | ||
"version": "1.2.1-alpha.1", | ||
"version": "1.2.1-alpha.2", | ||
"description": "Designed to be used with MobX-State-Tree to create asynchronous actions using RxJS.", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
import { addDisposer } from 'mobx-state-tree' | ||
import { Observable, Subject } from 'rxjs' | ||
import type { PayloadFunc, AnyInstance } from '../types' | ||
import type { PayloadFunc, AnyInstance, NormalizeOptionalPayload } from '../types' | ||
import type { ValidEffectActions } from './action' | ||
import { subscribe } from './utils' | ||
export type EffectFactory<P> = (payload$: Observable<P>) => Observable<ValidEffectActions> | ||
export type EffectFactory<P> = ( | ||
payload$: Observable<NormalizeOptionalPayload<P>>, | ||
) => Observable<ValidEffectActions> | ||
@@ -10,0 +12,0 @@ export type EffectDispatcher<P> = PayloadFunc<P, void> |
@@ -23,8 +23,12 @@ import type { IAnyModelType, Instance } from 'mobx-state-tree' | ||
export type NormalizeOptionalPayload<Payload> = IsOptionalPayload<Payload> extends true | ||
? Exclude<Payload, void> | undefined | ||
: Payload | ||
export type PayloadFunc<Payload, ReturnType> = IsEmptyPayload<Payload> extends true | ||
? () => ReturnType | ||
: IsOptionalPayload<Payload> extends true | ||
? (payload?: Exclude<Payload, undefined | void>) => ReturnType | ||
? (payload?: NormalizeOptionalPayload<Payload>) => ReturnType | ||
: (payload: Payload) => ReturnType | ||
export type AnyInstance = Instance<IAnyModelType> |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
101219
1500