flock 0.0.1 copy "flock: ^0.0.1" to clipboard
flock: ^0.0.1 copied to clipboard

outdated

Coordinate Flutter widgets' states with event sourcing.

flock #

Coordinate Flutter widgets' states with event sourcing.

Inspired by Redux.

Usage #

import 'package:flock/flock.dart';

// Events
class E {}
class EA extends E {}
class EB extends E {}

// EventStore
final eventStore = createEventStore<E>();

// Your projector

final projector = (int prev, EventStack<E> events, Projectable<E> store) {
  var result = prev ?? 0;
   // notice the events are in reverse chronological order
  for (var event in events) {
    projectCount++;
    if (event is EB)
      result += event.v;
    else if (event is EA)
      result -= int.tryParse(event.value) ?? 0;
  }
  return result;
};

// In you widget:

eventStore.subscribe((E e){
  final projection = eventStore.projectWith(projector);
  // update your state
});

Limits #

This is still an early WIP. The future plan includes:

  • better Flutter integration
  • serialization & time travel support

License #

MIT

0
likes
0
pub points
0%
popularity

Publisher

unverified uploader

Coordinate Flutter widgets&#x27; states with event sourcing.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on flock