@adwd/observe-component

0.1.1 • Public • Published

@adwd/observe-component

Observe component to subscribe/unsubscribe rxjs Observable.

import React from 'react';
import { interval } from 'rxjs/observable/interval';
import { map } from 'rxjs/operators';

import Observe from '@adwd/observe-component';

class Example extends Component {
  timer$ = interval(100);
  users$ = interval(500).pipe(map(i => `user${i}`));

  render() {
    return (
      <Observe source={{ timer: this.timer$, users: this.users$ }}>
        {({ timer, users }) => (
          <div>
            <p>timer: {timer}</p>
            <p>user: {users}</p>
          </div>
        )}
      </Observe>
    );
  }
}

Package Sidebar

Install

npm i @adwd/observe-component

Weekly Downloads

0

Version

0.1.1

License

MIT

Unpacked Size

86.2 kB

Total Files

10

Last publish

Collaborators

  • adwd