question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Dedicated composer for redux

See original GitHub issue

Hello, what do you think about having a composeWithRedux dedicated method like react-komposer-redux provides? I think it would DRY up little bit the composers. I would submit a PR if you think it is a good idea.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:3
  • Comments:8 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
markshustcommented, Jul 1, 2016

Just sent a PR. This is a very basic helper for Redux that avoids the need to call onData twice (and needing subscribe().

I’m using this with Mantra. Here is sample usage:

import { useDeps, composeAll } from 'mantra-core';
import composeWithRedux from '/client/modules/core/libs/with_redux';
import Header from '../components/Header';

const onPropsChange = ({ context }, onData) => {
  const { Store } = context();
  const { title } = Store.getState().header;

  onData(null, {
    title,
  });
};

const depsMapper = context => ({
  context: () => context,
});

export default composeAll(
  composeWithRedux(onPropsChange),
  useDeps(depsMapper),
)(Header);

By default it will look in context prop for Store object. The name can be overridden by passing in a storeName options param, and the store itself can be passed in as an option:

Custom name:

export default composeAll(
  composeWithRedux(onPropsChange, null, null, {storeName: 'CustomName'),
  useDeps(depsMapper),
)(Header);

Passing in store (needed if mantra isn’t used):

export default composeAll(
  composeWithRedux(onPropsChange, null, null, {store: Store),
  useDeps(depsMapper),
)(Header);
0reactions
arunodacommented, Nov 8, 2016

@markoshust could you submit a data loader generator for Redux as suggested here. (It’s for react-komposer v2)

May be for mobx as well.

Idea is to have them outside of the core repo. Anyway, we could link them in the README.

Read more comments on GitHub >

github_iconTop Results From Across the Web

compose | Redux
This example demonstrates how to use compose to enhance a store with applyMiddleware and a few developer tools from the redux-devtools package.
Read more >
anish000kumar/redux-box - GitHub
It organizes your store as collection of independent modules which can be used across different stores/applications/platforms. redux_box. Illustration by Vikas ...
Read more >
Creating Redux and Redux Saga components
You need Redux and Redux Saga components to create the wishlist-view react component. About this task. Complete the following steps to create Redux...
Read more >
Toby Driver & Co. [Redux] - Rate Your Music
Although probably best known as the "mastermind" behind the progressive/avant-rock groups Kayo Dot and maudlin of the Well, his career as an individual...
Read more >
Marsyas Redux — Simon Holt
The contest was brought about by the hubris of the satyr who dared to think that he was the greater musician. Inevitably, Marsyas...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found