cell 1.0.0-rc.4 copy "cell: ^1.0.0-rc.4" to clipboard
cell: ^1.0.0-rc.4 copied to clipboard

Foundation layer of the Cell Framework — Cells, Nucleus, Context, Deputy Pattern, and Conactive execution with Causal Integrity.

cell #

Reactive state for Dart. A cell holds a value or relays a signal. A pulse is the immutable message that moves a change. Operators (Cell.state, Cell.observe, …) wire cells together.

Dart License Version Status

Validation, deputies, provenance, and timing control are available when you need them. Defaults are pass-through and allow-all — you can ship a counter without learning Nucleus.

This is the foundation package of the Cell Framework (Mitosis). Sibling packages add collections, relations, stream combinators, persistence, and codegen.


When it fits #

Cell is a good match if you want:

  • Persistent reactive state with an explicit update path
  • Events (clicks, sockets, sensors) entering the same graph as state
  • Validation that is a gate, not a callback you remember to call
  • Restricted views of the same data without copying it (deputy, unmodifiable)
  • Multi-cell commits (transaction) or staged commands with undo (txApply)
  • Debounce / throttle / batch as library behavior rather than ad-hoc Timers

It is more machinery than you need for a couple of flags, a basic form, or a single Future. For Rx-style combinators (merge, zip, scan, windows), use cell_flow.


Install #

The package is on pub.flutter-io.cn. From this monorepo:

dependencies:
  cell: ^1.0.0-rc.4

From git:

dependencies:
  cell:
    git:
      url: https://github.com/simon-m-lee/cell.git
      path: packages/cell

Requires Dart >=3.5.0 <4.0.0.

import 'package:cell/cell.dart';

Quick example #

import 'package:cell/cell.dart';

void main() {
  final counter = Cell.state<int>(
    initial: 0,
    evolve: (host, input) {
      final delta = input.payload as int? ?? 1;
      return Pulse(host.value + delta);
    },
  );

  final observer = Cell.observe(
    source: counter.cell,
    effect: (pulse) => print('Counter: ${pulse.payload}'),
  );

  counter.update(5); // prints: Counter: 5
  observer.stop();
}

evolve returning null rejects the update. Omit evolve to treat update as a direct assignment.

Runnable demos live in example/. Start with example/state_demo.dart.


Core operators #

You can build most application graphs from these factories. None of them require configuring Receptor, TestCell, Context, or Synapses.

Factory Use when
1 Cell.state Persistent mutable state
2 Cell.ingress Manual emit / ingest of external events
3 Cell.observe Side effects; start / stop
4 Cell.derive Pure projection of one source
5 Cell.debounce Emit after a silence window
6 Cell.distinct Skip equal consecutive payloads
7 Cell.throttle Cap emission frequency
8 Cell.synthesis Aggregate several sources
9 Cell.asyncMap Map each value to a Future (concurrency, latestOnly, exhaust)
10 Cell.hub Route by Pulse.type
11 Cell.switchMap Follow the latest inner cell
12 Cell.fromFuture / Cell.fromStream Bridge dart:async
13 Cell.sanitized Redact before egress
14 Cell.open Manual topology (emit / link)
15 Cell.transaction Multi-cell buffered writes
16 Cell.txApply Staged apply + compensation

Also implemented, outside that numbered set: Cell.valve (predicate gate). Fan-in of several sources is Cell.synthesis (or combinators in cell_flow).

Learning order: get data in → hold state → react → shape streams → go async → combine → isolate writes. Operators 1–4 are enough for a first app.


How much you need to know #

Layers are optional, not a reading list.

  1. Operators — intended default for application code.
  2. Pipelines and propagation — custom Receptor / Instruction, and Synapses + PropagationPolicy, when a factory’s default is not enough.
  3. Validation and authorityTestCell and Context. Off by default (TestCell.allowAll, Context.system).
  4. InternalsNucleus, Cell.governed, Cell.fromNucleus, lifecycle policies. For extending the framework or high-integrity nodes.

A deputy is a proxy, not a copy: cell == cell.deputy() is true. Rules on a deputy can only narrow what the principal already allows.

See ARCHITECTURE.md for the design rationale.


Documentation #

Document What it is
HowTo-Start.md Walkthrough of the core concepts
HowTo-16_Essential_Operators.md Operator reference and learning path
FEATURES.md Source-checked feature catalog
ARCHITECTURE.md Why the pieces are shaped this way
TEST_VERIFICATION.md Unit-test inventory, measured coverage, and how to run the suite
HowTo-TestCell.md Validation rules
HowTo-Synapses.md Linking, filters, propagation
HowTo-Receptor.md Transformation pipelines
HowTo-Instruction.md Instruction stages
HowTo-Transaction.md Buffered multi-cell writes
HowTo-TransactionOnApply.md Staged apply + compensation
HowTo-Advanced.md Index of optional governance machinery

Guides use HowTo-*.md (hyphens). Generate API docs with dart doc . and open doc/api/index.html.

If a guide and the source disagree, the source is current.


Ecosystem #

Package Delivery Adds
cell (this) Now Nodes, pulses, operators, governance, transactions
cell_flow Now 100+ instruction factories on Flow, plus fluent chaining (mapTo, asyncExpand, zip, …)
cell_tissue Now Reactive collections (list / map / set / queue)

Flutter has no dedicated widgets here. Bind with Cell.observe (or an adapter) and drive setState or your existing state library.


Status #

RC (Mitosis 1.0.0-rc.4, Release Candidate). Public APIs for cells, pulses, operators, and transactions are exercised by a passing unit-test suite. Breaking changes remain possible before a versioned 1.0 stable.

A fuller developer list is in KNOWN_ISSUES.md. Known limits, so this page does not over-promise:

  • Published to pub.flutter-io.cn.
  • Context, PulseContext, and Sensitivity let you attach classification, actor, and purpose. They do not implement or certify GDPR, HIPAA, PCI-DSS, or any other regulation. Context.describe('…') stores text; it is not a legal basis or an audit log.

Feedback and issues are useful at this stage.

dart analyze lib
# Files are test_*.dart — bare `dart test` finds nothing. See TEST_VERIFICATION.md.
dart test @(Get-ChildItem test/test_*.dart | ForEach-Object { "test/$($_.Name)" })
dart format .
dart doc .

License #

MIT or Apache-2.0. See LICENSE.

Authors #

Lee Man Hoi Simon. See AUTHORS for copyright holders.

0
likes
140
points
168
downloads

Documentation

Documentation
API reference

Publisher

verified publisheropencell.dev

Weekly Downloads

Foundation layer of the Cell Framework — Cells, Nucleus, Context, Deputy Pattern, and Conactive execution with Causal Integrity.

Homepage
Repository (GitHub)
View/report issues

Topics

#state-management #reactive #concurrency #architecture #immutability

License

unknown (license)

Dependencies

meta, synchronized, uuid

More

Packages that depend on cell