harvest 1.3.1 copy "harvest: ^1.3.1" to clipboard
harvest: ^1.3.1 copied to clipboard

outdated

Event store for Dart with multiple backends

Build Status

Harvest #

Harvest is a event store for Dart with multiple backends. Harvest creates and persists streams of events, where each persistent event stream is identified by a Guid for future retrival.

Quick Guide #

1. Add the folowing to your pubspec.yaml and run pub install

    dependencies:
      harvest: any

2. Add harvest to some code and run it

main() {
	var streamId = new Guid();
	var eventStore = new MemoryEventStore();
	// get a event stream for streamId 
	var eventStream = eventStore.openStream(streamId);
	
	// create some events
	var event1 = ...
	var event2 = ...
	
	// store them
	eventStream.addAll([event1, event2]);
	eventStrem.commitChanges();
}	

Why do this ? #

Event sourcing is the concept of saving and retriving object state by the events that occured on them rather than by their current state. Consider the following bank use case:

  1. User creates account
  2. User deposits 10$
  3. User withdraws 2$

In a CRUD application you would now have a BankAccount object with an amount property with the value 8. In a event sourced application you have a BankAccount object and 3 events for it

  1. AccountCreated
  2. AmountDeposited
  3. AmountWithdrawn

Where is this useful? #

  • For certain applications the eventlog can be useful in itself such as a audit trail in a financial system.
  • It can help manage complexity in large applications by forcing programmers to make event types for every action that can occur.
  • It makes debugging easy since you can replay the event log to recreate any former system state where an error occurred.
  • It makes mobile app synchronization a breeze, since the offline app can just queue up events and replay them on the backend once it comes online.
  • In applications using the CQRS architecture pattern.

For more information, see the provided example application.

Supported Storage Engines #

Currently DartStore implements the following event stores.

  • Memory engine: suitable for testing purposes
  • IndexDB: suitable for web applications (work in progress)
  • Cordova: suitable for mobile applications (work in progress)
0
likes
0
points
19
downloads

Publisher

unverified uploader

Weekly Downloads

Event store for Dart with multiple backends

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

log4dart, meta, uuid

More

Packages that depend on harvest