Skip to content

kryptt/react-bacon

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

react-bacon

A little module for using React with Bacon.js.

Here's a JSFiddle!

Here's another one from @bebraw that does stuff with weather forecasts!

Installation

For browserify projects, npm install --save react-bacon.

For other projects, use the UMD distribution in /dist/react-bacon.js.

If you are just putting it in a <script> tag, the library will be at window.ReactBacon.

Usage

Right now the library includes a single React mixin, BaconMixin.

BaconMixin provides a few different methods for your components:

component.streamProps([propName])

Returns a memoized Bacon.Property backed by the component's props, skipping duplicate values. When a propName is present, the values of the property are those of the given prop. If no propName is given, the property's values are the whole props objects of the component.

The properties returned are cleaned up with a Bacon.End when the component unmounts.

component.streamState([stateName])

Like streamProps(propName), but for state values.

component.eventStream(functionName)

Registers an event handler function on the component with the given name, which simply sends its argument to the returned Bacon stream.

The stream is memoized by the functionName, and gets cleaned up with a Bacon.End when the component unmounts.

component.plug(observable, [stateKey])

Plugs a Bacon observable into the component's state, and returns an unsubscribe function. If a stateKey is given, then values from the observable are assigned to the given key. If no stateKey is given, the values must be objects which are passed directly to setState to assign multiple state keys at once.

The component will unsubscribe from the stream when it unmounts.

Packaging

browserify --standalone ReactBacon src/react-bacon.js -o dist/react-bacon.js

About

A little module for using React with Bacon.js

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 56.2%
  • LiveScript 43.8%