Articles

Announcing EventStore Client for Dart

Kenneth Gulbrandsøy  |  20 September 2021

 

DISCOOS, the community-driven initiative to create open-source software for search and rescue and disaster relief communications, has created an EventStoreDB client for Dart. It is a high-quality and community-developed package that brings EventStoreDB to Dart and Flutter developers. 

The DISCOOS community is working hard to make the client fully compliant with all the EventStoreDB gRPC Client APIs. Make sure to Star and Watch the GitHub repository for further updates.

EventStoreDart

Which features are supported?

As of version 0.2.1 all core features are supported, which include

  • Reading and appending events to streams
  • Managing subscriptions on streams
  • Managing projections for complex event processing
  • Managing persistent subscriptions for competing consumers

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.

The strategy for implementation in Dart

The code has been structured and classes named to be in line with the official Dotnet client in C#. As Dart has excellent support for async/await and streams, where appropriate there are code patterns native to Dart when C# doesn't yield effective Dart code

Getting started

This 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 dependency eventstore_client: ^0.2.1to pubspec.yaml
  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(
      '',
    ),
  );

  // Fetch all events in EventStore
  final result = await client.readFromAll(
    forward: true,
    resolveLinks: true,
    position: LogPosition.start,
  );

  // Only print if read was successful
  if (result.isOK) {
    await for (var event in result.stream) {
      print(event);
    }
  }
}

Now you can event source effectively in Dart! There will be more updates in the future, so keep checking back for further updates.


This post has been edited and rewritten from a version that appeared on Medium with the author's permission.