Git Product home page Git Product logo

chainable-components's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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  avatar

chainable-components's Issues

Parity with recompose

I'd like to have direct replacements for or at least an explanation of how one would emulate every hoc from recompose, as that library is so prevalent

I took a cursory glance at the documentation and came up with this graph:

emoji meaning
โœ… covered
๐Ÿšง feasible, not implemented yet
๐Ÿค” need to think on it
๐Ÿ˜ง ๐Ÿ˜ง
hoc explanation
โœ… mapProps() this is just cc.map(a => b)
โœ… withProps() this is just CC.of({})
๐Ÿค” withPropsOnChange()
๐Ÿค” withHandlers()
โœ… defaultProps() is just CC.of({})
โœ… renameProp() is just cc.map(a => b)
โœ… renameProps() is just cc.map(a => b)
โœ… flattenProp() is just cc.map(a => b)
โœ… withState()
๐Ÿค” withStateHandlers()
๐Ÿšง withReducer()
โœ… branch() is just fork()
โœ… renderComponent() is just fork(true ), maybe could add a special case?
โœ… renderNothing() is just fork(true, () => null
๐Ÿšง shouldUpdate()
โœ… pure() is just pure() โ€ฆ not sure this is a good one to promote, though?
โœ… onlyUpdateForKeys() is just pure()
๐Ÿคทโ€โ™€๏ธ onlyUpdateForPropTypes()
๐Ÿšง withContext()
๐Ÿšง getContext()
โœ… lifecycle() withLifecycle()
๐Ÿ˜ง toClass()
โœ… toRenderProps()
โœ… fromRenderProps()

For the "handlers" hocs, I think it makes the most sense to just implement something like the useCallback hook, and then they are just different mappings/combinations of that chainable.

Concerns about the ap method

I just heard about this library on the react round up podcast.
It's awesome I really like what this library is doing.

I have one concern and that is the use of the ap method
ap from a functional programming perspective should have the type signature

ap :: F( A -> B ) -> F( A ) -> F( B )

So in a chainable component it should return a chainable

The ap defined in the library may make more sense being call renderWith

The applicative interface would also be an excellent addition to help combine two independant
Chainables

From:

const withTwoState = props => {
  return (
    <WithState initial={0}>
      {outer => (
        <WithState initial={42}>
          {inner => (
            props.children({inner, outer})
          )}
        </WithState>
      )
    </WithState>
  );
}

With Chain:

const withTwoState = 
  withState({initial: 0}).chain(outer => 
    withState({initial: 42}).map(inner => 
      ({inner, outer})
    )
  )

Using the the applicative interface you can tidy it up
With Ap:

Chainable.of( outer => inner => ({ outer, inner }))
  .ap(withState({initial: 0}))
  .ap(withState({initial: 42}))

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.