0.0.1 • Published 7 years ago

rxx v0.0.1

Weekly downloads
3
License
MIT
Repository
github
Last release
7 years ago

rxx

Reactive JSX

Version Downloads Dependency status Build status License

Use Observables as JSX bindings

Installation

npm install --save rxx

Usage

import * as rxx from 'rxx';

const Counter = () => {
    const increments = new Subject()
    const decrements = new Subject()

    const count = merge(increments.mapTo(1), decrements.mapTo(-1))
        .scan((prev, change) => prev + change, 0)

    return (
        <div>
            {count}
            <button onclick={() => increments.next()}>+</button>
            <button onclick={() => decrements.next()}>-</button>   
        </div>
    )
}

document.body.appendChild(<Counter />)

Configuration

TypeScript

Add to tsconfig.json:

"jsx": "react",
"jsxFactory": "rxx.createElement",

Babel

Add to your .babelrc:

"plugins": [
  ["transform-react-jsx", {"pragma": "rxx.createElement"}]
]