Relay: network activity callbacks from DefaultNetworkLayer

Created on 5 May 2016  Â·  5Comments  Â·  Source: facebook/relay

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.

Most helpful comment

@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 [email protected] wrote:

Closed #1120 https://github.com/facebook/relay/issues/1120.

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub
https://github.com/facebook/relay/issues/1120#event-652154692

All 5 comments

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?

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

@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 [email protected] wrote:

Closed #1120 https://github.com/facebook/relay/issues/1120.

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub
https://github.com/facebook/relay/issues/1120#event-652154692

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

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

HsuTing picture HsuTing  Â·  3Comments

scotmatson picture scotmatson  Â·  3Comments

MartinDawson picture MartinDawson  Â·  3Comments

leebyron picture leebyron  Â·  3Comments

staylor picture staylor  Â·  3Comments