Redux integrations for Relay
Redux integration for Relay
react-relay-redux
lets you listen and respond to Relay
queries and mutations using Redux actions and reducers.
Eventually I want to look into how you can possibly dispatch queries/mutations directly using Redux actions, but that is a WIP.
$ npm install --save react-relay-redux
RegisterRelayDispatcher
react-relay-redux
exports a RelayNetworkDispatch
function that
takes your Relay environment and a dispatch
function for your
Redux store.
import Relay from 'react-relay'
import {RegisterRelayDispatcher} from './react-relay-redux'
import store from 'your-redux-store'
/* register a network subscriber */
RegisterRelayDispatcher(Relay.Store, store.dispatch)
/* then pass it to your renderer or root container */
<Relay.Renderer
environment={Relay.Store}
...
RelayReduxActions
You can import and use the following actions:
RELAY_QUERY
- when a Relay query is issuedRELAY_QUERY_SUCCESS
- when a Relay query is successfulRELAY_MUTATION
- when a Relay mutation is issuedRELAY_MUTATION_SUCCESS
- when a Relay mutation is successfulRELAY_{QUERY,MUTATION}_FAILURE
support