patronum
Version:
☄️ Effector utility library delivering modularity and convenience
42 lines (41 loc) • 2.35 kB
TypeScript
import { Effect, Event, Store, UnitTargetable, UnitValue, EventCallable, EventCallableAsReturnType } from 'effector';
type NoInfer<T> = [T][T extends any ? 0 : never];
type NonFalsy<T> = T extends null | undefined | false | 0 | 0n | '' ? never : T;
type SourceUnit<T> = Store<T> | Event<T> | Effect<T, any, any>;
export declare function condition<Payload, Then extends Payload = Payload>(options: {
source?: undefined;
if: ((payload: Payload) => payload is Then) | Then;
then?: UnitTargetable<NoInfer<Then> | void>;
else?: UnitTargetable<Exclude<NoInfer<Payload>, Then> | void>;
}): EventCallableAsReturnType<Payload>;
export declare function condition<Payload, Then extends NonFalsy<Payload> = NonFalsy<Payload>>(options: {
source?: undefined;
if: BooleanConstructor;
then?: UnitTargetable<NoInfer<Then> | void>;
else?: UnitTargetable<Exclude<NoInfer<Payload>, Then> | void>;
}): EventCallableAsReturnType<Payload>;
export declare function condition<Payload>(options: {
source?: undefined;
if: ((payload: Payload) => boolean) | Store<boolean> | NoInfer<Payload>;
then?: UnitTargetable<NoInfer<Payload> | void>;
else?: UnitTargetable<NoInfer<Payload> | void>;
}): EventCallableAsReturnType<Payload>;
export declare function condition<Payload extends UnitValue<Source>, Then extends Payload = Payload, Source extends SourceUnit<any> = SourceUnit<Payload>>(options: {
source: Source;
if: ((payload: Payload) => payload is Then) | Then;
then?: UnitTargetable<NoInfer<Then>>;
else?: UnitTargetable<Exclude<NoInfer<Payload>, Then>>;
}): Source;
export declare function condition<Payload extends UnitValue<Source>, Then extends NonFalsy<Payload> = NonFalsy<Payload>, Source extends SourceUnit<any> = SourceUnit<Payload>>(options: {
source: Source;
if: BooleanConstructor;
then?: UnitTargetable<NoInfer<Then> | void>;
else?: UnitTargetable<Exclude<NoInfer<Payload>, Then>>;
}): EventCallable<Payload>;
export declare function condition<Payload extends UnitValue<Source>, Source extends SourceUnit<any> = SourceUnit<Payload>>(options: {
source: SourceUnit<Payload>;
if: ((payload: Payload) => boolean) | Store<boolean> | NoInfer<Payload>;
then?: UnitTargetable<NoInfer<Payload> | void>;
else?: UnitTargetable<NoInfer<Payload> | void>;
}): Source;
export {};