4O4 / lua-reactivex

Reactive Extensions for Lua

Home Page:https://luarocks.org/modules/4O4/reactivex

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Lua-ReactiveX Build Status Coverage Status

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.

Getting Started

Lua

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")

Luvit

Install using lit:

lit install 4O4/reactivex

Then require it:

local rx = require("reactivex")

Love2D

See RxLove.

Example Usage

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.

Resources

Tests

Uses lust. Run with:

lua tests/runner.lua

or, to run a specific test:

lua tests/runner.lua skipUntil

License

MIT

About

Reactive Extensions for Lua

https://luarocks.org/modules/4O4/reactivex

License:MIT License


Languages

Language:Lua 100.0%