Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/effector/packages/effector/index.d.ts>sample

Business logic with ease ☄️
Latest
function sample
import { sample } from "https://deno.land/x/effector@effector-vue%4023.1.0/packages/effector/index.d.ts";

Represents a step in a business logic workflow. It tells an application when it should act, which data it needs, how it should be transformed and what should happens next

sample({
  // when clickBuy event is triggered
  clock: clickBuy,
  // read state of $shoppingCart store
  source: $shoppingCart,
  // and if there at least one item in cart
  filter: (cart) => cart.items.length > 0,
  // then select items from cart
  fn: cart => cart.items,
  // and pass results to buyItemsFx effect and clearCart event
  target: [buyItemsFx, clearCart]
})

Type Parameters

Target
Source
Clock
FLBool
FNInfSource extends (Source extends Unit<any> | SourceRecord ? TypeOfSource<Source> : never)
FNInfClock extends (Clock extends Units ? TypeOfClock<Clock> : never)
FilterFun extends (Source extends Unit<any> | SourceRecord ? Clock extends Units ? (never | ((src: TypeOfSource<Source>, clk: TypeOfClock<Clock>) => src is FNInfSource) | ((src: TypeOfSource<Source>, clk: TypeOfClock<Clock>) => boolean)) : (never | ((src: TypeOfSource<Source>) => src is FNInfSource) | ((src: TypeOfSource<Source>) => boolean)) : Clock extends Units ? (never | ((clk: TypeOfClock<Clock>) => clk is FNInfClock) | ((clk: TypeOfClock<Clock>) => boolean)) : never)
FN extends (Source extends Unit<any> | SourceRecord ? Clock extends Units ? (src: TypeOfSource<Source>, clk: TypeOfClock<Clock>) => any : (src: TypeOfSource<Source>) => any : Clock extends Units ? (clk: TypeOfClock<Clock>) => any : never)
FNInf extends (Source extends Unit<any> | SourceRecord ? Clock extends Units ? (src: FNInfSource, clk: TypeOfClock<Clock>) => any : (src: FNInfSource) => any : Clock extends Units ? (clk: FNInfClock) => any : never)
FNNonFalsy extends (Source extends Unit<any> | SourceRecord ? NonFalsy<TypeOfSource<Source>> : Clock extends Units ? NonFalsy<TypeOfClock<Clock>> : never)
FNAltArg extends (Source extends Unit<any> | SourceRecord ? Clock extends Units ? (src: FNNonFalsy, clk: TypeOfClock<Clock>) => any : (src: FNNonFalsy) => any : Clock extends Units ? (clk: FNNonFalsy) => any : never)
SomeFN
SourceNoConf
ClockNoConf
FNSrcNoConf extends (SourceNoConf extends Unit<any> | SourceRecord ? (src: TypeOfSource<SourceNoConf>) => any : never)
FNBothNoConf extends (SourceNoConf extends Unit<any> | SourceRecord ? ClockNoConf extends Units ? ((src: TypeOfSource<SourceNoConf>, clk: TypeOfClock<ClockNoConf>) => any) : never : never)
FLUnit
Args extends any[]
InferTarget

Parameters

...args: SourceNoConf extends Unit<any> | SourceRecord ? ClockNoConf extends Units ? [any, any, any] extends Args ? [SourceNoConf, ClockNoConf, FNBothNoConf] & Args : [any, any] extends Args ? [SourceNoConf, ClockNoConf] & Args : never : [any, any] extends Args ? [SourceNoConf, FNSrcNoConf] & Args : Args extends [Unit<any>] ? [SourceNoConf] & Args : SampleImpl<Target, Source, Clock, FLBool, FilterFun, FN, FNInf, FNInfSource, FNInfClock, FNAltArg, FLUnit, SomeFN> : SampleImpl<Target, Source, Clock, FLBool, FilterFun, FN, FNInf, FNInfSource, FNInfClock, FNAltArg, FLUnit, SomeFN>

Returns

SourceNoConf extends Unit<any> | SourceRecord ? ClockNoConf extends Units ? [any, any, any] extends Args ? SourceNoConf extends Store<any> ? ClockNoConf extends Store<any> ? Store<ReturnType<FNBothNoConf>> : EventAsReturnType<ReturnType<FNBothNoConf>> : EventAsReturnType<ReturnType<FNBothNoConf>> : [any, any] extends Args ? SourceNoConf extends Store<any> ? ClockNoConf extends Store<any> ? Store<TypeOfSource<SourceNoConf>> : EventAsReturnType<TypeOfSource<SourceNoConf>> : EventAsReturnType<TypeOfSource<SourceNoConf>> : never : [any, any] extends Args ? SourceNoConf extends Store<any> ? Store<ReturnType<FNSrcNoConf>> : EventAsReturnType<ReturnType<FNSrcNoConf>> : Args extends [Unit<any>] ? SourceNoConf extends Store<any> ? Store<TypeOfSource<SourceNoConf>> : EventAsReturnType<TypeOfSource<SourceNoConf>> : NoInfer<SampleRet<Target, Source, Clock, FLUnit, FLBool, FilterFun, FN, FNAltArg, FNInf, FNInfSource, FNInfClock, SomeFN, InferTarget>> : NoInfer<SampleRet<Target, Source, Clock, FLUnit, FLBool, FilterFun, FN, FNAltArg, FNInf, FNInfSource, FNInfClock, SomeFN, InferTarget>>