smallorange-reactive-store-react

1.0.3 • Public • Published

CircleCI

React Component for Small Orange Reactive Store

It attaches observables helpers to react components, and automatically tearsdown when destroyed;

Methods

	on(...filter: string, replay: boolean = false): Observable<any>;
	once(...filter: string, replay: boolean = false): Observable<any>;
	trigger(key: string, data: any = null): void;

Usage

	import React from 'react';
	import {
		Component
	} from 'smallorange-reactive-store-react';

	export class Messages extends Component {
		constructor(props) {
			super(props);

			this.state = {
				data: []
			};
		}

		componentDidMount() {
			this.on('inputChange')
				.subscribe(doSomething);

			this.once('destroy')
				.subscribe(() => console.log('Bye!'));
		}

		render() {
			return (
				<input type="text" onChange={e => this.trigger('inputChange', e)}>
			);
		}
	}

Readme

Keywords

none

Package Sidebar

Install

npm i smallorange-reactive-store-react

Weekly Downloads

2

Version

1.0.3

License

ISC

Last publish

Collaborators

  • feliperohde