Skip to content

beckyconning/tcomb-kefir

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tcomb-kefir

tcomb-kefir provides Tcomb type combinators for Kefir streams and properties.

This allows you to create streams and properties that have typesafe values.

Example

Here we create a typesafe function greet. It takes a string Tcomb.Str and returns a stream of strings TcombKefir.stream(Tcomb.Str).

var Tcomb = require('tcomb'),
    Kefir = require('kefir'),
    TcombKefir = require('./src/tcomb-kefir'),
    readline = require('readline'),
    rlInterface = readline.createInterface({ input: process.stdin, output: process.stdout }),
    greet = Tcomb.func(Tcomb.Str, TcombKefir.stream(Tcomb.Str))
        .of(function(greeting) {
            var question = "What would you like to be called? ",
                ask = function(callback) { rlInterface.question(question, callback) },
                answer = Kefir.fromCallback(ask),
                append = function(name) { return greeting + " " + name + "!"; };

            return answer.map(append).onValue(rlInterface.close.bind(rlInterface));
        });

greet("Hi there").onValue(console.log.bind(console));

About

Tcomb types for Kefir observables

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published