Relay: Provide access to pending variables in `props.relay.pendingVariables`

Created on 14 Apr 2016  路  4Comments  路  Source: facebook/relay

In 0.8.0, calling setVariables will always perform a new fetch; Relay no longer compares the next variables to the fetched variables to skip if identical. This means that users may need to check the pending variables to manually avoid refetching the same variables that are already in flight.

The proposal is for RelayContainer to pass the pending variables to components as this.props.relay.pendingVariables, where pending variables is null if there is no pending fetch, and is an object of the pending variables if there is an in-flight setVariables or forceFetch. Note that this also serves as a simple "is loading" check (e.g. isLoading = !!props.relay.pendingVariables).

enhancement help wanted

Most helpful comment

PRs welcome!

All 4 comments

This can be a very nice addition, it's currently not very easy to check loading state on the variable change. One have to listen to onReadyStateChange and mingle with, eg, component the state.

PRs welcome!

This should be fixed with release 0.9.1.

@Globegitter you're right, thanks for the reminder. This is done!

Was this page helpful?
0 / 5 - 0 ratings