createEffect
Method for creating an effect
#
createEffect with handlerCreates an effect with given handler
Arguments
handler
(Function): function to handle effect calls, also can be set withuse(handler)
Returns
Effect: New effect
note
You must provide a handler either in createEffect or in .use
method later, otherwise effect will throw with "no handler used in %effect name%" error
since
effector 21.3.0
#
Examples#
Create effect with handler#
Change state on effect completion#
Set handler to effect after creating#
Watch effect status#
createEffect with configCreates an effect with handler and name from given config object
Arguments
config
? (Params): effecthandler
(Function): function to handle effect calls, also can be set withuse(handler)
name
? (string): Optional effect name
Returns
Effect: New effect