🚀 Big News:Socket Has Acquired Secure Annex.Learn More →
Socket
Book a DemoSign in
Socket

recompose-etc

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

recompose-etc

React function components and higher-order components based on recompose and RxJS

latest
Source
npmnpm
Version
0.4.0
Version published
Weekly downloads
11
-15.38%
Maintainers
1
Weekly downloads
 
Created
Source

recompose-etc

GitHub License NPM version Build status dependency status devDependency Status peerDependency Status Greenkeeper badge

What is it?

A bunch of RxJS-based React components that build on those in recompose.

Why might you need it?

At the moment, recompose-etc is something of an experiment. It seems interesting, but I'm only just starting to use it for real-world development.

recompose provides the componentFromStream component factory and the mapPropsStream higher-order component. This package builds upon those and provides two render-prop-based component factories:

  • transformProps
  • transformEvent

transformProps applies an RxJS-based transform to the properties passed from the parent component to a child - via a render prop. The render prop can be specified as a render property, a children property or a child function. An example might look something like this:

const Component = transformProps(props$ => props$.pipe(auditTime(0, animationFrame)));
const element =
  <Component
    auditedValue={highFreqValue}
    render={({ auditedValue }) => (<span>{auditedValue}</span>)}
  />;

The specified transform could apply any structural or temporal RxJS transformation to the props. It could be as simple as an auditTime or debouceTime operator, or it could be something more complicated - like an observable that connects to the Firebase FireStore.

transformEvent applies an RxJS-based transform to an event passed from a child to a parent - via a handler function. An example might look something like this:

const Component = transformEvent(event$ => event$.pipe(
  debounceTime(1000),
  distinctUntilChanged((left, right) => left.target.value === right.target.value)
));
const element =
  <Component
    handler={handleChange}
    render={({ handler }) => (<input onChange={handler} type="text"/>)}
  />;

The package's debounceEvent, debounceProps and limitToFrameRate build upon the base component factories, incorporating some specifically-composed observables.

Keywords

observable

FAQs

Package last updated on 25 Apr 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts