Reactive Extensions for Lua

Bjorn 16edbf9fee Merge pull request #51 from bonzini/master 5 years ago
doc f9ff630135 Add an assertion like 'expect(observable).to.produce.error()' to test 'onError'. 6 years ago
examples 4b0833d44e Rename fromValue to of; 8 years ago
rockspec 763ab162cd Add 0.0.3 rockspec; 8 years ago
src 1cbd5b2ca6 flatten: avoid early completion 5 years ago
tests 1cbd5b2ca6 flatten: avoid early completion 5 years ago
tools 8b825ffc44 Update tools build version; 6 years ago
.editorconfig 1e3c1d542b Add editorconfig 5 years ago
.luacov c6688ff79e Test for 5.3 and luajit 2.1. 8 years ago
.travis.yml c6688ff79e Test for 5.3 and luajit 2.1. 8 years ago
LICENSE d64834faa6 Initial commit; 10 years ago
README.md ef6f80be0b Update README; 6 years ago
rx.lua 1cbd5b2ca6 flatten: avoid early completion 5 years ago

README.md

RxLua Build Status Coverage Status

Reactive Extensions for Lua.

RxLua 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.

Getting Started

Lua

Copy the rx.lua file into your project and require it:

local rx = require 'rx'

You can also install RxLua using luarocks:

luarocks install bjornbytes/rxlua

Luvit

Install using lit:

lit install bjornbytes/rx

Then require it:

local rx = require 'rx'

Love2D

See RxLove.

Example Usage

Use RxLua to construct a simple cheer:

local Rx = require 'rx'

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.

Resources

Tests

Uses lust. Run with:

lua tests/runner.lua

or, to run a specific test:

lua tests/runner.lua skipUntil

License

MIT, see LICENSE for details.