Adding onReadyStateChange callback to setVariables

`this.props.relay.setVariables` takes an optional callback that's not currently represented in the types. Just adding that.

See this answer on StackOverflow for a high-level overview:
http://stackoverflow.com/questions/35471836/loading-indicator-after-this-props-relay-setvariables-triggered-fetch

And the docs have more detailed information about what the callback provides:
https://facebook.github.io/relay/docs/guides-ready-state.html
This commit is contained in:
Matt Martin
2016-12-08 09:31:32 -08:00
committed by GitHub
parent ac7fdf1498
commit d0c8f10aa1
+25 -2
View File
@@ -103,8 +103,31 @@ declare module "react-relay" {
renderFailure?(error: Error, retry: Function): JSX.Element
}
type ReadyStateEvent =
'ABORT' |
'CACHE_RESTORED_REQUIRED' |
'CACHE_RESTORE_FAILED' |
'CACHE_RESTORE_START' |
'NETWORK_QUERY_ERROR' |
'NETWORK_QUERY_RECEIVED_ALL' |
'NETWORK_QUERY_RECEIVED_REQUIRED' |
'NETWORK_QUERY_START' |
'STORE_FOUND_ALL' |
'STORE_FOUND_REQUIRED';
interface OnReadyStateChange {
(readyState: {
ready: boolean,
done: boolean,
stale: boolean,
error?: Error,
events: Array<ReadyStateEvent>,
aborted: boolean
}): void
}
interface RelayProp {
variables: any
setVariables(variables: Object): void
variables: any
setVariables(variables: Object, onReadyStateChange?: OnReadyStateChange): void
}
}