Code Monkey home page Code Monkey logo

react-callbag-listener's Introduction

๐Ÿ‘‚ React Callbag Listener

NPM Downloads Build Status codecov.io


So you've seen the light and accepted Callbags as the future of reactive front-end development, but you need to update a React component every time a callbag emits a new value?

๐Ÿ‘‚ React Callbag Listener is the answer!


Demo ๐Ÿ‘€

Edit ๐Ÿ‘‚ React Callbag Listener Demo


Installation

npm install --save react-callbag-listener

or

yarn add react-callbag-listener

How it works

You provide any number of callbags as props to ๐Ÿ‘‚ React Callbag Listener, and the render function given as children will be rendered whenever any of them changes.

import CallbagListener from 'react-callbag-listener'

...

// foo$ and bar$ are callbag sources that will emit values
<CallbagListener foo={foo$} bar={bar$}>
  {({ foo, bar }) => (
    <div>
      <div>Foo value is: {foo}</div>
      <div>Bar value is: {bar}</div>
    </div>
  )}
</CallbagListener>

That's it. There are no other options or API to document. The object given to your render prop will have the same keys as you passed as callbag props.

react-callbag-listener's People

Contributors

andarist avatar erikras avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

react-callbag-listener's Issues

Removed props don't get unsubscribed

Correct me if I'm wrong (I'm already sleepy ๐Ÿ˜‰), but I think if we remove a props between renders old (removed) prop/callbag won't get unsubscribed, because you only iterate through current props in the componentDidUpdate hook.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.