orchestra 1.0.2 copy "orchestra: ^1.0.2" to clipboard
orchestra: ^1.0.2 copied to clipboard

Reactive state management for Dart and Flutter. Clean architecture, deterministic logic, and built-in DevTools Inspector.

example/lib/main.dart

import 'package:orchestra/orchestra.dart';

import 'features/counter_feature.dart';

void main() async {
  // Create the orchestrator with the counter orchestration.
  final orchestrator = Orchestrator(
    name: 'CounterApp',
    orchestrations: {CounterOrchestration()},
  );

  // Activate the orchestrator to start the orchestration and systems.
  orchestrator.activate();

  // Retrieve the shared entities from the orchestrator.
  final counter = orchestrator.get<CounterValue>();
  final increment = orchestrator.get<IncrementEvent>();
  final decrement = orchestrator.get<DecrementEvent>();
  final reset = orchestrator.get<ResetEvent>();

  // Print current counter value whenever it changes.
  counter.addListener(_CounterPrinter());

  print('Orchestra core example — interactive counter');
  print('Commands:  +  increment   -  decrement   r  reset   q  quit\n');

  print('Counter will be incremented in 2 seconds...');
  await Future.delayed(const Duration(seconds: 2));
  increment.trigger();
  print('Counter incremented!');

  print('Counter will be reset in 2 seconds...');
  await Future.delayed(const Duration(seconds: 2));
  reset.trigger();
  print('Counter reset!');

  print('Counter will be decremented in 2 seconds...');
  await Future.delayed(const Duration(seconds: 2));
  decrement.trigger();
  print('Counter decremented!');
}

final class _CounterPrinter implements EntityListener {
  @override
  void onEntityChanged(Entity entity) {
    final counter = entity as CounterValue;
    print('Counter: ${counter.value}');
  }
}
0
likes
160
points
0
downloads

Documentation

API reference

Publisher

verified publisherwinchetechnologies.co.uk

Weekly Downloads

Reactive state management for Dart and Flutter. Clean architecture, deterministic logic, and built-in DevTools Inspector.

Repository (GitHub)
View/report issues

Topics

#state-management #architecture #reactive #devtools

License

Apache-2.0 (license)

More

Packages that depend on orchestra