The library is intended to be used with @mfjs/compiler to turn JavaScript into reactive programming language.
$ npm install --save-dev @mfjs/compiler
$ npm install --save @mfjs/core rx @mfjs/rx
$ mfjsc input-file.js -o dist
# or for browser
$ npm install --save-dev browserify @mfjs/compiler
$ npm install --save @mfjs/core rx @mfjs/rx
$ browserify -t @mfjs/compiler/monadify input.js -o index.js
Since Observable monad is quite heavy it is better to use the library with minimal profile where only values wrapped with M are bound.
const M = require('@mfjs/core')
const RxM = require('@mfjs/rx')()
RxM.run(function() {
for (let i = 1; i < 4; ++i)
M.yield(i)
M.empty();
})
Will return observable signaling 1,2,3.
The call to require('@mfjs\rx')
returns function for constructing
monad definition object. There are a few options:
latest
- by default monad will use flatMap as in original RX .NET LINQ mapping, but if this field is true it will instead use flatMapLatestexception
- the resulting monad will useObservable::catch
andObservable::handle
functions for encoding try-catch statement. Or otherwise by default it will use default token based control signaling.wrap
- this option doesn’t change semantics but it wraps Observable into a wrapper so original Observable prototype isn’t changed.
Copyright © 2016 Vitaliy Akimov
Distributed under the terms of the The MIT License (MIT).