← Blogg

Announcing EventStore Client for Dart

We are pleased to announce the first EventStore Client for Dart, a high quality and community developed Dart package that brings the industry-leading event sourcing capabilities of EventStoreDB to the community of Dart and Flutter developers.

EventStore + Dart = pub.dev loves it
EventStore + Dart = pub.dev loves it

As a community we are committed to making this client fully compliant with all EventStoreDB gRPC Client APIs. We are not there yet, so make sure you watch and star the repository on GitHub to keep updated.

What is EventStoreDB?

EventStoreDB is an open-source, functional database built for event sourcing and complex event processing. It supports consistent reading and idempotent appending of events with optimistic concurrency to individual streams, which lets you build systems with consistency guaranteed by EventStoreDB. For more on event sourcing, see The Beginner’s Guide to Event Sourcing.

Which features are supported?

As of version 0.2.1 all core features are supported:

All of the administration APIs for users, access control, operations and monitoring are still in progress. You can follow the progress and roadmap on GitHub.

Our strategy for implementation in Dart

We have, to a large extent, structured code and named classes, methods and parameters the same as in the official client in C#, so that the official documentation and our implementation align. Dart has excellent support for async/await and streams, though, so where appropriate we opt for code patterns native to Dart when the C# patterns do not yield effective Dart code.

Getting started

We are working on an introduction to event sourcing in Dart. In the meantime, here is how you get started with EventStore Client in Dart:

  1. Create a single node or cluster in EventStore Cloud (or deploy your own).

  2. Create an appropriate connection string.

  3. Add the dependency to your pubspec.yaml:

    dependencies:
      eventstore_client: ^0.2.1
  4. Create an instance of EventStoreClient with the given connection string:

    import 'package:eventstore_client/eventstore_client.dart';
    
    void main() async {
      // Create a client instance
      final client = EventStoreStreamsClient(
        EventStoreClientSettings.parse('<your value>'),
      );
    
      // Fetch events from given stream in EventStore
      final result = await client.read(
        'some-stream-id',
        forward: true,
        position: StreamPosition.start,
      );
    
      // Only print if read was successful
      if (result.isOK) {
        await for (var event in result.stream) {
          print(event);
        }
      }
    }
    read_from_stream_example.dart GitHub view raw

And you are ready for event sourcing all-the-things.

We love contributions and feedback

DISCO Open Source is a small community of highly devoted developers and subject experts. We built this client for another project, but we thought sharing the implementation with the Dart and Flutter community was the best option. Any contributions or feedback are highly appreciated.

Opprinnelig publisert på DISCOOS’ side på Medium 3. september 2021.