create-subscription #12325
create-subscription #12325
Conversation
47af8a3
to
11e741c
11e741c
to
d5d8bf6
Details of bundled changes.Comparing: ad9544f...6f740d9 create-subscription
Generated by |
f8ee765
to
4304b55
@@ -254,6 +254,16 @@ const bundles = [ | |||
global: 'SimpleCacheProvider', | |||
externals: ['react'], | |||
}, | |||
|
|||
/******* Simple Cache Provider (experimental) *******/ |
flarnie
Mar 5, 2018
Contributor
nit - update comment
nit - update comment
bvaughn
Mar 5, 2018
Author
Contributor
D'oh 😁
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
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 |
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...