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

network activity callbacks from DefaultNetworkLayer #1120

Closed
bmcmahen opened this issue May 5, 2016 · 5 comments
Closed

network activity callbacks from DefaultNetworkLayer #1120

bmcmahen opened this issue May 5, 2016 · 5 comments

Comments

@bmcmahen
Copy link

bmcmahen commented May 5, 2016

I'm developing a react-native app using relay and would find network activity callbacks useful from the DefaultNetworkLayer. It would allow me to centralize management of the StatusBarIOS network activity indicator if I could tell when a) an active request has started, and b) the request has ended (either successfully, or with an error).

I think I could do a PR for this relatively easily, if there's interest. The alternatives to this approach would be to use the readyState in Relay.Renderer or to build my own custom network layer. The problem with the first approach is that, especially in mobile apps, you end up with Relay.Renderer calls throughout the app, and sometimes the readyState doesn't indicate whether the data is being fetched from the cache, or over the network layer.

@josephsavona
Copy link
Contributor

In general we'd prefer to keep the default network layer as simple as possible. To add custom functionality such as network activity callbacks, you can compose the default implementation in your own object/class with whatever hooks you need. Does this work for your use case?

@bmcmahen
Copy link
Author

bmcmahen commented May 6, 2016

Makes sense. I'll give composing the default implementation a try. Thanks.

@bmcmahen bmcmahen closed this as completed May 6, 2016
@KyleAMathews
Copy link
Contributor

@ben you might be interested in this recent effort
https://github.com/nodkz/react-relay-network-layer

On Thu, May 5, 2016 at 6:15 PM Ben McMahen notifications@github.com wrote:

Closed #1120 #1120.


You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub
#1120 (comment)

@bmcmahen
Copy link
Author

bmcmahen commented May 6, 2016

For what it's worth, composing the default implementation was super easy and proved perfect for the task.

@KyleAMathews
Copy link
Contributor

Cool! Big props to @nodkz for taking this on.

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

3 participants