如何从redux_epic调用错误操作?

时间:2019-02-14 17:38:18

标签: dart flutter

我正在尝试这样做:

Stream<dynamic> searchEpic(
  Stream<PerformSearchAction> actions,
  EpicStore<AppState> store,
) {
  return actions.asyncMap((action) => fetchPost()
      .then((results) => SearchResultsAction(results['title']))
      .catchError((error) => SearchErrorAction(error.message)));
}

但是我收到以下错误消息:

  

类型“ SearchErrorAction”不是类型“ FutureOr SearchResultsAction”的子类型

1 个答案:

答案 0 :(得分:0)

我只需要将要通过管道工作的类型定义为dynamic,就像这样:

Stream<dynamic> searchEpic(
  Stream<PerformSearchAction> actions,
  EpicStore<AppState> store,
) {
  return actions.asyncMap<dynamic>((action) => fetchPost()
      .then<dynamic>((results) => SearchResultsAction(results['title']))
      .catchError((error) => SearchErrorAction(error.message)));
}