Skip to content

krawaller/callbag-connect-react

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 

callbag-connect-react

A utility for connecting a React component with Callbag sources. Comparable to ReactRedux, but for Callbags instead of Redux!

npm install callbag-connect-react

usage

import connect from 'callbag-connect-react

@connect(
  { // Objects are assumed to contain sourcess
    propName: source1,
    ...
  },
  [ // Arrays are assumed to contain signals
    [source2, callback],
    ...
  ]
})
class MyComponent extends React {
  ...
}

Now;

  • Whenever source1 emits data, that will be sent to the propName prop in MyComponent.
  • Whenever source2 emits, callback will be invoked with (componentInstance, emission).

Sources

An object where the keys are prop names and values are sources. When a source emits, the corresponding prop will be populated.

Signals

An array of tuples, each tuple is an array with a source and a callback. Whenever the source emits, the callback will be called with the component instance and the emitted data.

Use signals when you want your component to do something other than render when a source emits.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published