cell 1.0.0-beta.2 copy "cell: ^1.0.0-beta.2" to clipboard
cell: ^1.0.0-beta.2 copied to clipboard

A programming framework provides a comprehensive reactive programming solution for Dart, with particular strength in managing complex state and data flow in applications.

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 #

  1. Reactive Programming Model: Automatic propagation of changes through a network of cells

  2. Validation System: Configurable rules for what operations are allowed

  3. Flexible Signal Processing: Customizable signal transformation and propagation

  4. Collection Support: Reactive versions of common collection types (Set, List, Queue, Value)

  5. Modifiable/Unmodifiable Views: Both mutable and immutable variants of all containers

  6. Asynchronous Support: Async interfaces for all modifiable operations

Core Components and Their Relationships #

  1. [Cell] - The Fundamental Reactive Unit

    Purpose: Acts as the basic building block of reactivity

  2. [Receptor] - Signal Processing

    Purpose: Handles signal transformation and propagation

  3. [Synapses] - Inter-Cell Communication

    Purpose: Manages connections between cells

  4. [Properties] - Cell Configuration

    Purpose: Contains all configurable aspects of a cell

  5. [TestRule]/[TestObject] - Validation System

    Purpose: Provides validation rules for cell operations

  6. [Signal] - Data Carrier

    Purpose: Carries data between cells

  7. [Deputy] - Delegation Pattern

    Purpose: Delegates to original [Cell] with reduced permissions or accesses

Key Architectural Patterns #

  1. Reactive Flow:

    • [Signal]s enter through [Receptor]

    • [TestObject] validates the [Signal]

    • If valid, processed by Receptor.transform

    • Output signal propagated via [Synapses]

  2. Decorator Pattern:

    • [Deputy] wraps cells to modify behavior

    • [CellAsync] adds asynchronous capabilities

  3. Composite Pattern:

    • [TestObject] can contain multiple [TestRule] instances

    • [Collective] types manage collections of cells using [CollectiveSet], [CollectiveList], [CollectiveQueue] and [CollectiveQueue].

  4. Strategy Pattern:

    • Different [Receptor] implementations handle signal processing

    • [Synapses] implementations vary propagation behavior

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.

0
likes
70
points
31
downloads

Publisher

verified publisheropencell.dev

Weekly Downloads

A programming framework provides a comprehensive reactive programming solution for Dart, with particular strength in managing complex state and data flow in applications.

Repository (GitHub)

Topics

#reactive #asynchronous #immutable #validation #collection

Documentation

API reference

License

unknown (license)

Dependencies

random_string

More

Packages that depend on cell