frp-d 1.1.0-alpha.1

Functional Reactive Programming (FRP) library.


To use this package, run the following command in your project's root directory:

Manual usage
Put the following dependency into your project's dependences section:

FRP-D: Functional Reactive Programming Library for D

This library is built from the ground up in order to take full advantage of some of Ds unique features.

Basic Usage

Cell Usage

void main() {
    auto a = cell!int(1);
    auto b = cell(2);
    
    auto product = cf!mul(a,b);
    auto currentProduct = mul(a.value,b.value);
    writeln("`product` is a: `Cell!int`");
    writeln("`currentProduct` is a: `int`");
    
    writeln(a.value," * ",b.value," = ",product.value);
    a.value = 2;
    writeln(a.value," * ",b.value," = ",product.value);
    b.value = 3;
    writeln(a.value," * ",b.value," = ",product.value);
    
    writeln("but `currentProduct` never changed: ",currentProduct);
}

Stream Usage

void main() {
    auto a = stream!int;
    auto b = stream!int;
    
    auto a3 = a.map!triple;
    auto a3b = join!((int[] l, int[] r)=>l~r)(a3,b);
    
    a3.addListener!((int v){writeln("Event in `a3`: ",v);});
    a3b.addListener!((int v){writeln("Event in `a3b`: ",v);});
    
    writeln("Order of listeners being called from events from the same source is undefined. (More technically, events in the same transaction.");
    a.put(1);
    writeln("--- Transation break.");
    b.put(2);
    writeln("--- Transation break.");
    a.put(5);
    writeln("--- Transation break.");
    a.put(6);
}

Contributing

If you have an interest is seeing a good FRP library native in D, join in the fun! I love colaborating!

If you have questions just ask.

Authors:
  • Jonathan Levi
Sub packages:
frp-d:cell, frp-d:stream
Dependencies:
none
Versions:
1.1.0-alpha.1 2019-Feb-01
1.0.0-beta.1 2019-Jan-25
~master 2019-Feb-01
~stream 2019-Feb-01
Show all 4 versions
Download Stats:
  • 0 downloads today

  • 0 downloads this week

  • 0 downloads this month

  • 0 downloads total

Score:
0.0
Short URL:
frp-d.dub.pm