Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

csp promises and async react components #6

Open
ThomasDeutsch opened this issue Nov 22, 2014 · 2 comments
Open

csp promises and async react components #6

ThomasDeutsch opened this issue Nov 22, 2014 · 2 comments

Comments

@ThomasDeutsch
Copy link

I used js-csp in my last project to replace promises (ajax) and frp (search logic).
With webpack + bundle-loader i am able to load components only when needed. webpack makes this very easy.

<AsyncComp data={dataCh} bundle={require('bundle?lazy!./file.js')};

This component will load the data and the bundle only when needed. Complete example here.

If more components are using data from dataCh or if the same component gets re-mounted to the DOM, the csp solution will fail, because the value will be taken and the AsyncComponent will wait for this never-arriving data.
At this point, csp-promises would be a nice solution.

I ended up loading all data to the immutable datastructure.
I am not happy with this solution because i think that loaded data should not be part of the app-state (in most cases). But i was able to utilize immutable-cursors.

I think that a csp-promise solution would be a competitor for immutable-cursors.
If a channel would return always the last value on every take, and if you could renew the resolved promise value (unlike real promises that could only be resolved once) - would this make immutable-cursors obsolete?

@getify
Copy link

getify commented Nov 22, 2014

I personally think you're asking for observables, not channel-promises.

@ThomasDeutsch
Copy link
Author

For the first part, promise-channels would be a nice solution for multiple components that will read from a single channel.

Maybe i am asking for observables, when it comes to "renewable" promise-channels. Because of "first value written wins", it would only make sense to use promise-channels if the receiver would wait for a new promise after the first resolved value is taken.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants