Skip to content
This repository was archived by the owner on Sep 10, 2022. It is now read-only.

Pass handlers object (self) to createHandler function#333

Closed
chrisui wants to merge 1 commit into
acdlite:masterfrom
chrisui:patch-2
Closed

Pass handlers object (self) to createHandler function#333
chrisui wants to merge 1 commit into
acdlite:masterfrom
chrisui:patch-2

Conversation

@chrisui

@chrisui chrisui commented Mar 17, 2017

Copy link
Copy Markdown
Contributor

This allows creation and reference of handlers in a single withHandlers call rather than many.

withHandlers({
  a: (props, handlers) => (...args) => handlers.b(...args),
  b: () => (...args) => doStuff(...arg),
})

Posting this here as a spitball idea. Will wrap up with tests if we think this is a fair addition to recompose!

This avoids the following requirement.

withHandlers({
  b: () => (...args) => doStuff(...arg),
})
withHandlers({
  a: (props) => (...args) => props.b(...args),
})

Note: this has definitely popped up as a somewhat edge usage 🤔

This allows creation and reference of handlers in a single `withHandlers` rather than many.
@istarkov

Copy link
Copy Markdown
Contributor

Idea super!
But have you tested your code as it seems like examples you provide will not work.
As handlers you use at createHandler are not the transformed handlers,
so to call b you need to call it like

withHandlers({
  a: (props, handlers) => (...args) => handlers.b(props, handlers)(...args),
  b: () => (...args) => doStuff(...arg),
})

and this is not cool.

@chrisui

chrisui commented Mar 17, 2017

Copy link
Copy Markdown
Contributor Author

Totally not tested the code! Just did a quick psuedo diff to demo the idea :)

@istarkov

Copy link
Copy Markdown
Contributor

As I said idea super!!! ;-)

@istarkov

istarkov commented Jun 7, 2017

Copy link
Copy Markdown
Contributor

see #401

@istarkov istarkov closed this Jun 7, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants