-
Notifications
You must be signed in to change notification settings - Fork 47k
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
create-subscription #12325
create-subscription #12325
Conversation
47af8a3
to
11e741c
Compare
11e741c
to
d5d8bf6
Compare
Details of bundled changes.Comparing: ad9544f...6f740d9 create-subscription
Generated by 🚫 dangerJS |
f8ee765
to
4304b55
Compare
scripts/rollup/bundles.js
Outdated
@@ -254,6 +254,16 @@ const bundles = [ | |||
global: 'SimpleCacheProvider', | |||
externals: ['react'], | |||
}, | |||
|
|||
/******* Simple Cache Provider (experimental) *******/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit - update comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
D'oh 😁
I can confirm that this, or something like it, will be essential for future React use with subscriptions. Will do a more in-depth review of the implementation later, but so far looks good and fits with all our learning from updating Relay. I also put it on the agenda for team sync. tomorrow. |
Cool! I like the idea of providing an foolproof way to do subscriptions in async. Some concerns:
|
Thanks for the feedback, @acdlite! Totally agreed with your second bullet point! I had that same concern based on past experiences with open source libs. 👍 As for your first concern, I'm on the fence about the best way to handle it. On the one hand, I want it to be as possible- but I hear your concern about encouraging people to use subscriptions in lieu of context.
I could export another HOC that ties into the context API, if you think it would be worth doing? It wouldn't be much extra code. |
I've updated the README with an API overview and some basic examples for event dispatchers and RxJS. I'd like to add more examples as I think of them. (Ideas welcome!) |
18c193f
to
c395051
Compare
I also added documentation and a test for native Promises, although it's a bit clunky. The lack of a way to "unsubscribe" could also result in memory leaks as long as something has a reference to the old Promise, but I think it's still worth documenting how they could be used. (I'm open for feedback here as well of course.) |
Just an FYI (in case I lose connectivity in the air) - as soon as I'm done writing more tests, I'm going to update this helper to only use the HOC approach for functional components. For class components, I'll use an "ES6 mixin" approach to retain |
Thanks, everyone, for the valuable input 👋 |
Since the source branch got deleted might want to edit first post to lead to https://github.com/facebook/react/blob/master/packages/create-subscription/README.md |
Done 👍 |
create-subscription provides an simple, async-safe interface to manage a subscription.
create-subscription provides an simple, async-safe interface to manage a subscription.
Async-safe subscriptions are hard to get right.
create-subscription
provides an simple, async-safe interface to manage a subscription.View the formatted README to learn more...