fmodel 0.1.0 copy "fmodel: ^0.1.0" to clipboard
fmodel: ^0.1.0 copied to clipboard

Functional domain modeling primitives for building event-sourced and state-stored Dart applications with CQRS.

example/main.dart

import 'package:fmodel/domain.dart';

enum CounterCommand { increment }

void main() async {
  final counter = Decider<CounterCommand, int, int>(
    decide: (command, state) async* {
      if (command == CounterCommand.increment) {
        yield 1;
      }
    },
    evolve: (state, event) => state + event,
    initialState: 0,
  );

  final events = await counter.decide(CounterCommand.increment, 0).toList();
  final nextState = events.fold(counter.initialState, counter.evolve);

  print('Counter state: $nextState');
}
0
likes
160
points
84
downloads

Documentation

API reference

Publisher

verified publisherdclimber.com

Weekly Downloads

Functional domain modeling primitives for building event-sourced and state-stored Dart applications with CQRS.

Homepage
Repository (GitHub)
View/report issues

Topics

#domain-driven-design #event-sourcing #functional-programming

License

Apache-2.0 (license)

More

Packages that depend on fmodel