Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

page之间数据如何通讯交互? #131

Closed
GordonHuangYong opened this issue Mar 27, 2019 · 7 comments
Closed

page之间数据如何通讯交互? #131

GordonHuangYong opened this issue Mar 27, 2019 · 7 comments

Comments

@GordonHuangYong
Copy link

GordonHuangYong commented Mar 27, 2019

现在有一个数据,需要从page的effect , dispatch到另个page的reducer, 如何实现?
我做了些尝试, 感觉少了点什么,所以才无效.
详情如下:
ctx.dispatch(xxActionCreator.xxfunction(xxparam));//无效
ctx.pageBroadcast(xxActionCreator.xxfunction(xxparam));//无效
ctx.appBroadcast(xxActionCreator.xxfunction(xxparam));报错

E/flutter (25936): [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: 'package:fish_redux/src/redux_component/provider.dart': Failed assertion: line 66 pos 12: 'provider != null': Please check if the AppProvider is mounted.
E/flutter (25936): #0 _AssertionError._doThrowNew (dart:core/runtime/liberrors_patch.dart:40:39)
E/flutter (25936): #1 _AssertionError._throwNew (dart:core/runtime/liberrors_patch.dart:36:5)
E/flutter (25936): #2 AppProvider.appBroadcast (package:fish_redux/src/redux_component/provider.dart:66:12)
E/flutter (25936): #3 DefaultContext.appBroadcast (package:fish_redux/src/redux_component/context.dart:86:17)
E/flutter (25936): #4 _viewDidLoad. (package:wt_assistant_v2/Pages/ScanDevice/effect.dart:43:11)
E/flutter (25936): #5 _rootRun (dart:async/zone.dart:1120:38)
E/flutter (25936): #6 _CustomZone.run (dart:async/zone.dart:1021:19)
E/flutter (25936): #7 _FutureListener.handleWhenComplete (dart:async/future_impl.dart:150:18)
E/flutter (25936): #8 Future._propagateToListeners.handleWhenCompleteCallback (dart:async/future_impl.dart:609:39)
E/flutter (25936): #9 Future._propagateToListeners (dart:async/future_impl.dart:665:37)
E/flutter (25936): #10 Future._complete (dart:async/future_impl.dart:473:7)
E/flutter (25936): #11 _SyncCompleter.complete (dart:async/future_impl.dart:51:12)
E/flutter (25936): #12 _AsyncAwaitCompleter.complete. (dart:async/runtime/libasync_patch.dart:33:20)
E/flutter (25936): #13 _rootRun (dart:async/zone.dart:1120:38)
E/flutter (25936): #14 _CustomZone.run (dart:async/zone.dart:1021:19)
E/flutter (25936): #15 _CustomZone.runGuarded (dart:async/zone.dart:923:7)
E/flutter (25936): #16 _CustomZone.bindCallbackGuarded. (dart:async/zone.dart:963:23)
E/flutter (25936): #17 _rootRun (dart:async/zone.dart:1124:13)
E/flutter (25936): #18 _CustomZone.run (dart:async/zone.dart:1021:19)
E/flutter (25936): #19 _CustomZone.runGuarded (dart:async/zone.dart:923:7)
E/flutter (25936): #20 _CustomZone.bindCallbackGuarded. (dart:async/zone.dart:963:23)
E/flutter (25936): #21 _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
E/flutter (25936): #22 _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)

@zjuwjf
Copy link
Contributor

zjuwjf commented Mar 27, 2019

目前需要 AppProvider 在最外层的包裹。面向application的需求,fish-redux做的不多。
你可以提在 #96 中表达你的想法,我们会对大家的想法做出一个roadmap,以此推动fish-redux的持续演进。

@tom1918
Copy link

tom1918 commented Mar 28, 2019

目前需要 AppProvider 在最外层的包裹。面向application的需求,fish-redux做的不多。
你可以提在 #96 中表达你的想法,我们会对大家的想法做出一个roadmap,以此推动fish-redux的持续演进。

我现在正如您说的 我试用了 flutter provide 这个组件用来做全局参数功能,但是对于fish-redux 的生命周期而言很不友好,期待你们的roadmap 但是想问问你们计划会在什么时候开源这个功能?

@hyjfine
Copy link
Contributor

hyjfine commented Mar 28, 2019

如果是登录状态这种信息或者你可以试试维护一个全局的store实例

@tom1918
Copy link

tom1918 commented Mar 29, 2019

如果是登录状态这种信息或者你可以试试维护一个全局的store实例

请教一下如何用 fish-redux 做一个全局的store 以及 使用 effect 和 reducer?

@GordonHuangYong
Copy link
Author

目前发现可以使用AppProvider实现跨页面传数据.
我介绍一下方法.可能很多人和我一样小白.
至于roadmpa什么的,我暂时不了解, 就不发炎了.

  1. 在main.dart中. app那里,最外层包裹.如图示.
  2. 发出action, 使用AppProvider.appBroadcast(ctx.context, xxActionCreator.onDoing(param));
  3. 在另一个page的effect中, 接收回调.不是在reduce中.在reducer无法接收, 原因不明.
    image

@hyjfine
Copy link
Contributor

hyjfine commented Mar 29, 2019

#90 看看这个示例调用是不是能满足你的需求

@zjuwjf zjuwjf closed this as completed in 8fd7a86 Mar 29, 2019
zjuwjf added a commit that referenced this issue Mar 29, 2019
@zjuwjf zjuwjf reopened this Mar 29, 2019
@zjuwjf
Copy link
Contributor

zjuwjf commented Mar 29, 2019

目前发现可以使用AppProvider实现跨页面传数据.
我介绍一下方法.可能很多人和我一样小白.
至于roadmpa什么的,我暂时不了解, 就不发炎了.

  1. 在main.dart中. app那里,最外层包裹.如图示.
  2. 发出action, 使用AppProvider.appBroadcast(ctx.context, xxActionCreator.onDoing(param));
  3. 在另一个page的effect中, 接收回调.不是在reduce中.在reducer无法接收, 原因不明.
    image

感谢反馈,已经在master分支上fixed。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants