Giter Site home page Giter Site logo

eventstore.reactive's Introduction

EventStore.Reactive

###Reactive subscriptions for EventStore (http://geteventstore.com)

EventStore subscriptions are by nature reactive and asyncronous. This project lets you create a typed observable EventStore subscription and use Reactive Extensions (https://rx.codeplex.com/) to work with it.

You get four generic classes that create different typed observables.

  • EventStore.Ractive.SubscriptionObservable<T> - to subscribe to all events of type T
  • EventStore.Ractive.SubscriptionStreamObservable<T> - to subscribe to events of type T from one stream
  • EventStore.Ractive.CatchupSubscriptionObservable<T> - to create a catch up subscription from all events of type T
  • EventStore.Ractive.CatchupSubscriptionStreamObservable<T> - to create a catch up subscription for type T from one stream

Each class implements IObservable<T>, so you can use all Rx extension methods like Buffer, Window, Distinct and so on, and subscribe to events using Subscribe(IObserver observer).

To get an observable, call one of the extension methods on IEventStoreConnection:

IObservable<TestEvent> onlineSubscription = 
    connection.CreateSubscriptionObservable<TestEvent>(false)
        .Subscribe(x => DumpEvent(x, "EventStoreObservable"));
IObservable<TestEvent> onlineStreamSubscription = 
    connection.CreateStreamSubscriptionObservable<TestEvent>("test-stream-1", false)
        .Subscribe(x => DumpEvent(x, "EventStoreStreamObservable for test-stream-1"));
IObservable<TestEvent> catchUpSubscription = 
    connection.CreateCatchUpSubscriptionObservable<TestEvent>(null, false, DumpPosition)
        .Subscribe(x => DumpEvent(x, "EventStoreCatchupObservable"));
IObservable<TestEvent> catchUpStreamSubscription =
    connection.CreateStreamCatchUpSubscriptionObservable<TestEvent>("test-stream-2", null, false, DumpPosition)
        .Subscribe(x => DumpEvent(x, "EventStoreCatchupStreamObservable for test-stream-2"));

Remember that these subscriptions receive all events from EventStore but your observer will only receive events of type T, all other events will b swallowed.

When EventStore subscription is dropped, your observer will either be called OnError if there was an exception, or OnComplete otherwise.

All observable subscription stops its underlying EventStore subscription when being disposed. For catch up subscriptions you can supply a delegate that will receive the last processed event position so you can save it for future use. This delegate is called when the subscription is stopped.

eventstore.reactive's People

Contributors

alexeyzimarev avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.