A reactive programming framework centered around the Cell class and its extensions,
particularly the Collective family of classes that implement reactive collections
CollectiveSet, CollectiveList, CollectiveQueue and CollectionValue
.
This framework provides a comprehensive reactive programming solution for Dart, with
particular strength in managing complex state and data flow in applications.
Features
-
Reactive Programming Model: Automatic propagation of changes through a network of cells
-
Validation System: Configurable rules for what operations are allowed
-
Flexible Signal Processing: Customizable signal transformation and propagation
-
Collection Support: Reactive versions of common collection types (Set, List, Queue, Value)
-
Modifiable/Unmodifiable Views: Both mutable and immutable variants of all containers
-
Asynchronous Support: Async interfaces for all modifiable operations
Core Components and Their Relationships
-
Cell - The Fundamental Reactive Unit
Purpose: Acts as the basic building block of reactivity
-
Receptor - Signal Processing
Purpose: Handles signal transformation and propagation
-
Synapses - Inter-Cell Communication
Purpose: Manages connections between cells
-
Properties - Cell Configuration
Purpose: Contains all configurable aspects of a cell
-
TestRule/TestObject - Validation System
Purpose: Provides validation rules for cell operations
-
Signal - Data Carrier
Purpose: Carries data between cells
-
Deputy - Delegation Pattern
Purpose: Delegates to original Cell with reduced permissions or accesses
Key Architectural Patterns
-
Reactive Flow:
-
TestObject validates the Signal
-
If valid, processed by
Receptor.transform
-
Output signal propagated via Synapses
-
Decorator Pattern:
-
Composite Pattern:
-
TestObject can contain multiple TestRule instances
-
Collective types manage collections of cells using CollectiveSet, CollectiveList, CollectiveQueue and CollectiveQueue.
-
-
Strategy Pattern:
Getting started
To use this package, add the following to your pubspec.yaml
file:
dependencies:
cell: ^<latest_version>
Then, run dart pub get
to install the package.
import 'package:cell/cell.dart';
import 'package:cell/collective.dart';
Usage
// Create a basic cell
final cell = Cell();
final boundCell = Cell(bind: cell);
// Create a listening cell
final listener = Cell.listen<String>(
bind: baseCell,
listen: (signal, _) => print('Received: ${signal.body}'),
);
// Create a transforming cell
final transformer = Cell.signaling<Signal<String>, Signal<int>(
bind: baseCell,
map: (signal, _) => Signal<int>(signal.body?.length),
);
Example: with Collective bounded
// Create source cell
final source = CollectiveValue<int>(5);
// Create transformed cell
final squared = Cell.signaling<int,int>(
bind: source,
transform: (signal, _) => Signal(signal.body * signal.body)
);
// Create logger
final logger = Cell.listen<int>(
bind: squared,
listen: (signal, _) => print('Value squared: ${signal.body}')
);
// Update source - automatically propagates
source.value = 10; // Logs "Value squared: 100"
Disclaimer
It is an A.I. generated document. The content is based on the code provided and may not accurately reflect the intended functionality or usage of the package. Please review and modify as necessary to ensure accuracy and clarity.
Libraries
- callable
- keywords
- cell Core
cell:core
is a reactive programming framework centered around the Cell class and its extensions, particularly the Collective family of classes that implement reactive collections CollectiveSet, CollectiveList, CollectiveQueue and CollectiveValue. This framework provides a comprehensive reactive programming solution for Dart, with particular strength in managing complex state and data flow in applications.- collective Core
cell:collective
library is a powerful Dart framework for building reactive data structures and event-driven systems. It provides a set of abstract and concrete classes that enable developers to create observable collections, manage state changes, and propagate signals throughout an application.