Reactive Extensions for Lua.
Lua-ReactiveX gives Lua the power of Observables, which are data structures that represent a stream of values that arrive over time. They're very handy when dealing with events, streams of data, asynchronous requests, and concurrency.
This is a friendly fork of RxLua. All credits for initial development go to the original author, bjornbytes.
This fork includes some fixes and features contributed by the community. There are also foundational changes here in order to introduce a proper automatic unsubscription mechanism which was missing and caused unexpected behavior in some cases. These changes are heavily inspired by the RxJS (5.x) internals, and thus RxJS is considered a reference implementation for all future development of Lua-ReactiveX.
Install with luarocks:
luarocks install reactivex
Or download a portable package from the Releases page, and extract reactivex.lua
file into your project. Then simply require it:
local rx = require("reactivex")
Install using lit
:
lit install 4O4/reactivex
Then require it:
local rx = require("reactivex")
See RxLove.
Use ReactiveX to construct a simple cheer:
local rx = require("reactivex")
rx.Observable.fromRange(1, 8)
:filter(function(x) return x % 2 == 0 end)
:concat(rx.Observable.of('who do we appreciate'))
:map(function(value) return value .. '!' end)
:subscribe(print)
-- => 2! 4! 6! 8! who do we appreciate!
See examples for more.
Uses lust. Run with:
lua tests/runner.lua
or, to run a specific test:
lua tests/runner.lua skipUntil