ActionChannel class
Creates an effect that instructs the middleware to queue the actions matching pattern using an event channel. Optionally, you can provide a buffer to control buffering of the queued actions.
Check Take effect for pattern definitions.
Example
The following code creates a channel to buffer all UserRequest
actions. Note that even the Saga may be blocked
on the Call effect. All actions that come while it's blocked are automatically buffered. This causes the Saga
to execute the API calls one at a time
import 'package:redux_saga/redux_saga.dart';
import 'api.dart';
//...
takeOneAtMost() sync* {
var chan = Result<Channel>();
yield ActionChannel(UserRequest, result: chan);
while (true) {
var action = Result();
yield Take(channel: chan.value, result: action);
yield Call(api.getUser, args: [action.value.payload]);
}
}
- Inheritance
-
- Object
- Effect
- EffectWithResult
- ActionChannel
Constructors
- ActionChannel(dynamic pattern, {Buffer? buffer, Result? result})
- Creates an instance of an ActionChannel effect
Properties
- buffer → Buffer?
-
An optional buffer can be provided to channel
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- pattern → dynamic
-
Queues actions to buffer that matching this pattern.
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