Coder Social home page Coder Social logo

roslynrx's Introduction

Roslyn Rx

A test project where I want to play with Roslyn and Reactive Extensions.

String based queries

Create string based filters and aggregations which are compiled into working Observable Queries. I haven't yet gotten to removing compiled types altogether, but the properties used in the query don't need to be defined at compile time.

A where clause:

var filter = new Filter<Event<long>>("@event => @event.Type == 1L && @event.Data > 30 && @event != null && @event.Data != 203123123");

var simpleObservable = Observable.Interval(TimeSpan.FromSeconds(1), scheduler)
                .Take(numberOfEvents)
                .Select(i => new Event<long>((int)i % numberOfTypes, i));

simpleObservable.Link(filter).Count().Subscribe(i => count = i).Subscribe(Console.Writeline);

An Rx scan:

var summer = new Scan<Event<long>>("(sum, @event) => new RoslynRx.Tests.Event<long>(0, sum.Data + @event.Data)");

Demuxing a stream into smaller streams:

    var dm = new Demuxer<int, Event<long>>(knownTypes, "@event => @event.Type");
    
    simpleObservable.Interval.Subscribe(dm);
    foreach (var stream in dm.Streams)
    {
        stream.Value.Count().Subscribe(Console.WriteLine);
    }

Todo

  • Remove types
  • Allow output of different types (i.e. summing gives an integer, rather than an instance of the event).
  • Composition
    var simpleObservable = Observable.Interval(TimeSpan.FromSeconds(1), scheduler)
                .Take(someEvents)
                .Select(i => new Event<long>((int)i % 12, i));    
    // Someday
    
    var query = @"
        where(\"@event => @event.Data > 3\")        
        demux(\"@event => @event.Type\", new[] { Type1, Type2, Type3 })
        count()
    ";
    simpleObservable.Link(new Query(query)).Subscribe();
    
    // yields
    //  1: 20 received
    //  2: 21 received
    //  3: 22 received
  • Duck typing

    Gracefully handle missindg parameters and warn / error.

  • UI

    That would probably be fun.

roslynrx's People

Watchers

James Cloos avatar Rob Rodi 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.