Refract
  • Read Me
  • Introduction
    • Why Refract?
    • Core Concepts
    • Thinking In Refract
    • Alternatives
  • Usage
    • Getting Started
    • Installation
    • Connecting To React
    • Observing React, Preact and Inferno
    • Injecting Dependencies
    • Observing Redux
    • Observing Anything
    • Handling Effects
    • Pushing to Props
    • Rendering Components
    • Handling Errors
    • Testing
  • Recipes
    • Dependency Injection
    • Creating An API Dependency
    • Handling state
    • Replacing Redux Connect
  • Examples
    • Debounced fetch
    • Counter
    • Field validation
    • Redux fetch
    • Routing
    • Typeahead
    • Visit time
  • API
    • compose
    • withEffects
    • toProps, asProps
    • useRefract
    • refractEnhancer (Redux)
  • Glossary
  • Feedback
Powered by GitBook
On this page
  • Packages
  • Signature
  • Example
  1. API

compose

Used for composing functions from right to left, it is a very useful utility for composing higher-order components in React, Inferno or Preact.

Packages

compose is provided by our React, Inferno or Preact packages - refract-*, refract-inferno-*, refract-preact-*.

Signature

compose will compose multiple function to create a function which takes a single argument.

compose = (...functions) => arg => result

Using compose with three functions f, g and h is the equivalent of arg => f(g(h(arg)))

Example

import { connect } from 'react-redux'
import { withEffects, compose } from 'refract-rxjs'

const WrappedComponent = compose(
    connect(mapStateToProps, mapDispatchToProps),
    withEffects(aperture)
)(BaseComponent)
PreviousAPINextwithEffects

Last updated 6 years ago