CloneableGenerator class

Takes a generator function (sync*) and returns a generator function. All generators instantiated from this function will be cloneable. For testing purpose only.

Example

This is useful when you want to test a different branch of a saga without having to replay the actions that lead to it.

 Iterable<int> testGen(int base) sync* {
   yield base;
   yield base + 1;
   yield base + 2;
   yield base + 3;
   yield base + 4;
 }

 var gen = CloneableGenerator(testGen, args: <dynamic>[0]);

 gen.moveNext();   //gen.current is 0
 gen.moveNext();   //gen.current is 1

 CloneableGenerator genCloned = gen.clone();

 gen.moveNext(); //gen.current is 2
 genCloned.moveNext(); //genCloned.current is 2
Implemented types

Constructors

CloneableGenerator(Function fn, {List? args, Map<Symbol, dynamic>? namedArgs})
Creates an instance of a CloneableGenerator

Properties

args List?
Arguments of the generator function to call
final
current → dynamic
The current element.
no setteroverride
fn Function
A Generator function to call and clone
final
hashCode int
The hash code for this object.
no setterinherited
namedArgs Map<Symbol, dynamic>?
Named arguments of the generator function to call
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

clone() CloneableGenerator
Clones the generator and both generator can resume from the same step.
moveNext() bool
Advances the iterator to the next element of the iteration.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
setResult(dynamic value) → void
Sets current effect result
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited