React Reactive Class
What?
With React Reactive Class, you can create Reactive Components, which subscribe Rx.Observables and re-render themselves.
Features
-
Reactive DOM elements: A set of reactive DOM elements (button, div, span, etc).
-
Reactive wrapper: A higher order component to wrap your existing component to be a Reactive Component.
Installation
npm install --save react-reactive-class
Usage
Use reactive DOM elements
;; ; const div:Div span:Span = dom; windowstyle$ = ;windowtext$ = ; Component { console; return <div> <h1>Demo</h1> <Div style=windowstyle$>Hello</Div> <Span>windowtext$</Span> </div> ; } React; // notice that App will not re-render, nice!windowstyle$;windowtext$;// you can open your console and play around
Use Reactive wrapper
ES5/ES6
; Component { console; return <div>thispropschildren</div> ; } const XText = ;
ES7
; @reactiveComponent { console; return <div>thispropschildren</div> ; }
Mount/unmount Reactive Component
Reactively compose components!
// Unmount this component if length of incoming text is 0.<Span mount= text$ > text$</Span>
Child component constraint
Source must be the only child when using observable as child component.
// This will not work<Span> Hello name$ how are you?</Span> // This will work<span> Hello <Span>name$</Span> how are you?</span>
Feedbacks are welcome!
Feel free to ask questions or submit pull requests!
License
The MIT License (MIT)