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.

React Komposer 2.x

See original GitHub issue

We’ve been pretty busy with some internal apps these days. Sorry for not updating. When we are building it and looking at some of these issues, I think we need to re-think about the API.

Here’s what we are looking to have in 2.x (Which will be out pretty soon).

import { makeComposer, merge } from 'react-komposer';
// Additional dataLoader generators are located in a different NPM package.
// These goes into the same repo. But multiple NPM modules. That's to have their own NPM modules for each of these.
import getPromiseLoader from 'react-komposer-promise';
import getRxLoader from 'react-komposer-rx';

// We need to this once in an app.
// With this, we could create our own base compose utility with our own options.
// Additionally, this'll allow us to use react-komposer under React Native since
// we don't have any loading and error components.
const compose = makeComposer({
  loading: () => (<div>Loading..</div>),
  error: (error) => alert(error.message),
  pure: true,
  propsToWatch: [], // Now dataLoader is re-run only when one of the props mentioned is changed. In this case, it only runs once.
  context: { // This is how we pass addition stuff to the dataLoader.
    reduxStore: {}
  }
});

// Now there's two callbacks onData and onError.
// That's because, we don't usually use onError.
// We may handle it via our own component rather using something global.
// We use the onError specially in prototyping the app.
const dataLoader = (props, onData, onError) => {
  // Fetch from the data.
  // We can access the context via this.
  //   For an example, we can get the reduxStore with `this.reduxStore`
  return aa.subscribe();
};

const now = Rx.Observable.interval(1000)
  .map(() => new Date().toString());

// Now composeAll is renamed into merge
const DataAwareComponent = merge(
  compose(dataLoader, { propsToWatch: ['appId'] }), // We could alter options like this.
  compose(getPromiseLoader(Promise.resolve(100), 'promiseData')),
  compose(getRxLoader(now, 'date')),
)(<Component/>);

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
arunodacommented, Nov 8, 2016

@macrozone we only use a single feature of recompose which is merge. It’s a few lines of code and I hope the API is bit different too.

We use react-komposer for data loading, but after that it’s possible to use recompose or use recomposed UI components with react-komposer.

0reactions
arunodacommented, Nov 8, 2016

Closing since I’ve released it. But feel free to open new issues for questions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

arunoda/react-komposer - GitHub
GitHub - arunoda/react-komposer: Feed data into React components by ... React Komposer 2.x is almost compatible with 1.x but with few minor changes....
Read more >
react/react - Packagist
ReactPHP: Event-driven, non-blocking I/O with PHP.
Read more >
The extension APIs in Bot Framework Composer
Learn about extensions (JavaScript modules) as a way to add features to your instance of the Composer application.
Read more >
How (and Why) to Update to Composer 2 - Mike Madison
x. Updating Composer itself is super simple! Just run: composer self-update. composer self-update Updating to version 2.0.7.
Read more >
Composing React Components with TypeScript - Pluralsight
In this guide, you will learn how to compose React.js components using the compile-to-JavaScript language, TypeScript. Using TypeScript with ...
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