rx 0.2.0

Reactive Extensions for D Programming Language.


To use this package, put the following dependency into your project's dependencies section:

dub.json
dub.sdl

Reactive Extensions for D Programming Language

Dub version MIT License Build Status

Overview

The is a library like the Rx.NET, for the asynchronous or event-based programs on OutputRange concept.

Example
import rx;
import std.algorithm : equal;
import std.array : appender;
import std.conv : to;

void main()
{
    auto subject = new SubjectObject!int;
    auto pub = subject
        .filter!(n => n % 2 == 0)
        .map!(o => to!string(o));

    auto buf = appender!(string[]);
    auto disposable = pub.subscribe(buf);

    foreach (i; 0 .. 10)
    {
        subject.put(i);
    }

    auto result = buf.data;
    assert(equal(result, ["0", "2", "4", "6", "8"]));
}

And more examples or Documents

Usage

Setting dependencies in dub.json

{
    ...
    "dependencies": {
        "rx": "~>0.1.0"
    }
}

or dub.sdl

dependency "rx" version="~>0.1.0"

License

This library is under the MIT License. Some code is borrowed from Rx.NET.

Concepts

Basic interfaces
//module rx.disposable
interface Disposable
{
    void dispose();
}

//module rx.observer
interface Observer(E) : OutputRange!E
{
    //void put(E obj); //inherits from OutputRange!E
    void completed();
    void failure(Exception e);
}

//module rx.observable
interface Observable(E)
{
    alias ElementType = E;
    Disposable subscribe(Observer!E observer);
}

Future work

  • more algorithms
  • more test
  • more documents
Authors:
  • lempiji
Dependencies:
none
Versions:
0.11.0 2019-May-03
0.10.1 2019-Feb-09
0.10.0 2019-Jan-26
0.9.0 2018-Jul-29
0.8.0 2018-Mar-25
Show all 26 versions
Download Stats:
  • 1 downloads today

  • 8 downloads this week

  • 17 downloads this month

  • 5212 downloads total

Score:
1.9
Short URL:
rx.dub.pm