Skip to content
This repository has been archived by the owner on Jul 4, 2019. It is now read-only.

Simpler API #4

Merged
merged 9 commits into from
Oct 24, 2017
Merged

Simpler API #4

merged 9 commits into from
Oct 24, 2017

Conversation

jxnblk
Copy link
Owner

@jxnblk jxnblk commented Sep 15, 2017

Rewrite to consolidate the two HOCs into a single HOC. If the component does not have a parent refunk context, it becomes the provider, and if there is a a parent context, it connects to state.

Note: this is a major breaking change

// example
import connect from 'refunk'
const App = props => <div />

// create a refunk state provider
export default connect(App)
import connect from 'refunk'
const TodoList = props => <div />

// connect to the parent refunk state
export default connect(TodoList)
// initialize state with props
<App todos={[]}>
  <TodoList />
</App>
  • Add channel prop support for namespacing refunk context

@jxnblk jxnblk changed the title WIP Rewrite API Rewrite API Sep 16, 2017
@jxnblk jxnblk changed the title Rewrite API Simpler API Sep 16, 2017
@nelix
Copy link

nelix commented Sep 25, 2017

This is kind of genius, the arguments connect accepts might be a little unforgiving to future features (and I think most decorators return a closure?).
connect({namespace: 'myLib', keys: ['someKey']})(MyApp) might be better... You could then also add an option to extend/replace/mask its parent (I often nest ThemeProviders, people might wanna use this in libs).

@jxnblk
Copy link
Owner Author

jxnblk commented Oct 23, 2017

@nelix Yeah, I want to get rid of the first arguments part and make React props the primary API for configuring the components. This also makes alternative APIs like #5 possible. For the namespace option that's sort of what I'm intending to add where I mention the channel prop, i.e. a way to have multiple refunk provider instances in a single app without colliding

@jxnblk jxnblk merged commit 47005aa into master Oct 24, 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