Reactjs 使用可观察到的重复次数管理阿波罗

Reactjs 使用可观察到的重复次数管理阿波罗,reactjs,redux,react-apollo,redux-observable,Reactjs,Redux,React Apollo,Redux Observable,我想用redux observable管理我的抓取,但我找不到任何示例。有人有答案吗 apollo vanillaJS这是获取我的查询结果的方法: const opts = {uri: 'http://localhost:8080/graphql'}; const networkInterface = createNetworkInterface(opts); const client = new ApolloClient({ networkInterface}); let query = g

我想用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' })....

谢谢

您可以像这样使用Promise中的运算符:

const fetchQuestionsEpic = action$ =>
  action$.ofType(FETCH_QUESTIONS)
  .mergeMap(() =>
    Observable.fromPromise(fetchQuestions())
      .map(questions => ({ type: QUESTIONS_FETCHED, questions })),
  );
本回购协议遵循一些良好做法