【发布时间】:2017-11-30 23:47:56
【问题描述】:
我想用 redux observable 管理我的获取,但我找不到任何示例。有人对此有答案吗?
通过 apollo vanillaJS,这是获取我的查询结果的方式:
const opts = {uri: 'http://localhost:8080/graphql'};
const networkInterface = createNetworkInterface(opts);
const client = new ApolloClient({
networkInterface});
let query = gql`query {
viewer {
id
firstName
lastName
defaultTimeZoneId
defaultLanguage
}
}`;
client.query({query}).then((results) => {})
//return a promise
现在我需要将它插入 redux observable 来管理答案:
export const fetchActionGridDataEpic = action$ =>
action$.ofType('FETCHING_ACTION_GRID_DATA')
//Execute the query then if networkStatus === 7 send the result to FETCHING_ACTION_GRID_DATA_FULFILLED as a payload
.mapTo({ type: 'FETCHING_ACTION_GRID_DATA_FULFILLED' })....
谢谢
【问题讨论】:
标签: reactjs redux react-apollo redux-observable