Take class
Creates an Effect description that instructs the middleware to wait for a specified action on the Store or if provided on the channel. The Generator is suspended until an action that matches pattern is dispatched.
The result of yield Take(pattern : pattern)
is an action object being dispatched.
pattern is interpreted using the following rules:
-
If
Take
is called without pattern argument or'*'
all dispatched actions are matched (e.g.Take()
will match all actions). -
If it is a function, the action is matched if
pattern(action)
is true. -
If it is a Type, the action is matched through its type. The logic is
action.runtimeType === pattern
(e.g.Take(pattern: IncrementAsync)
. Type matcher may be enough to solve most scenarios. It is also type safe and easy to use. -
If it is a String, the action is matched if its type name as string equals the String. The logic is
action.runtimeType.toString() === pattern
(e.g.Take(pattern: 'IncrementAsync')
. -
If it is an array, each item in the array is accepted as pattern and all must match, so the mixed array of types, strings and function predicates is supported. The most common use case is an array of types though, so that action type is matched against all items in the array (e.g.
Take(pattern: [Increment, Decrement])
and that would match either actions of typeIncrement
orDecrement
).
The middleware provides a special action End. If you dispatch the End action, then all Sagas blocked on a Take Effect will be terminated regardless of the specified pattern. If the terminated Saga has still some forked tasks which are still running, it will wait for all the child tasks to terminate before terminating the Task.
- Inheritance
-
- Object
- Effect
- EffectWithResult
- Take
- Implementers
Constructors
Properties
- channel → Channel?
-
Instructs the middleware to wait for a specified message from the provided Channel.
If the channel is already closed, then the Generator will immediately terminate
following the same process described for
Take
.final - hashCode → int
-
The hash code for this object.
no setterinherited
- maybe → bool
-
If true
Take
does not automatically terminate the Saga on an End action. Instead all Sagas blocked on a take Effect will get the End object. Check TakeMaybe also.final - pattern → dynamic
-
Actions only matching pattern is taken.
final
- result ↔ Result?
-
Result after effect is resolved.
getter/setter pairinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
getDefinition(
) → Map< String, dynamic> -
Returns all properties of effect as a dictionary object
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited