pocketflow_extensions library
Dart-specific extensions for PocketFlow.
This library contains convenience classes and patterns that are specific to the Dart implementation and are not part of the core Python PocketFlow runtime. These extensions provide additional functionality and patterns that leverage Dart's type system and language features.
Usage
import 'package:pocketflow/pocketflow_extensions.dart';
// Use core classes
final node = SimpleAsyncNode((input) async => input * 2);
// Use extension classes
final batchNode = IteratingBatchNode<int, int>();
final parallelFlow = ParallelNodeBatchFlow([node1, node2]);
final streamingFlow = StreamingBatchFlow([node1, node2]);
Extensions Included:
-
IteratingBatchNode: A convenience class for processing batches by iterating over individual items with automatic retry logic per item.
-
ParallelNodeBatchFlow: A flow that executes multiple nodes in parallel for each item in a batch, useful for independent operations on each item.
-
StreamingBatchFlow: A flow that processes batches sequentially through a pipeline of nodes, where each node receives and modifies the entire batch.
These extensions are designed to complement the core PocketFlow library and provide additional patterns for common use cases in Dart applications.
For detailed documentation and examples, see EXTENSIONS.md.
Classes
- AsyncBatchFlow
- An asynchronous batch flow that runs the flow multiple times with different parameters.
-
AsyncBatchNode<
I, O> - A class for defining nodes that process a batch of items asynchronously in sequential order.
- AsyncFlow
-
A class for orchestrating flows with
asyncnodes. - AsyncNode
- A class for defining nodes with true async lifecycle methods.
- AsyncParallelBatchFlow
- An asynchronous parallel batch flow that runs the flow multiple times in parallel with different parameters.
-
AsyncParallelBatchNode<
I, O> - A class for defining nodes that process a batch of items asynchronously and in parallel.
- BaseNode
- An abstract class representing a node in a workflow.
-
BatchFlow<
I, O> - A BatchFlow is a specialized Flow that processes a batch of inputs.
-
BatchNode<
I, O> -
A concrete class for processing a batch of items of type
Iand returning a batch of items of typeO. - ConditionalTransition
- A helper class to represent a pending conditional transition.
- Flow
- A Flow is a specialized BaseNode that orchestrates the execution of a graph of nodes. It manages the flow of data and control between nodes.
-
InheritanceAsyncBatchNode<
I, O> - An AsyncNode that processes batches of items asynchronously using inheritance.
-
IteratingBatchNode<
I, O> - An abstract node that processes a batch of items by iterating over them.
- Node
- A class that represents a node in a PocketFlow workflow.
-
ParallelNodeBatchFlow<
TIn, TOut> - A flow that processes a batch of items by executing a set of nodes in parallel for each item.
- SimpleAsyncNode
- A convenience class that wraps a function as an AsyncNode.
-
StreamingBatchFlow<
TIn, TOut> - A flow that processes a batch of items sequentially through a series of nodes.
Mixins
-
BatchNodeMixin<
I, O> - A mixin that provides batch processing capabilities for synchronous nodes.
Typedefs
-
AsyncBatchItemExecFunction<
I, O> = Future< O> Function(I item) - A function type for an asynchronous batch item execution block.
- AsyncExecFunction = Future Function(dynamic prepResult)
- A function type for an asynchronous execution block.
-
AsyncParallelBatchItemExecFunction<
I, O> = Future< O> Function(I item) - A function type for an asynchronous, parallel batch item execution block.