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

How to integrate fluro with fish-redux? #395

Open
tianlinzx opened this issue Jul 15, 2019 · 14 comments
Open

How to integrate fluro with fish-redux? #395

tianlinzx opened this issue Jul 15, 2019 · 14 comments
Labels
good first issue Good for newcomers the key issue the key issue

Comments

@tianlinzx
Copy link

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
Is it possible to integrated fluro with fish-redux ?

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
Fluro need to define a Router object as below
final router = new Router(); Routes.configureRoutes(router); Application.router = router;

In fish-redux ,we also needs to define an object PageRoutes
final AbstractRoutes routes = PageRoutes

How to integrate fluro with fish-redux ?

Additional context
Add any other context or screenshots about the feature request here.

@zjuwjf
Copy link
Contributor

zjuwjf commented Jul 15, 2019

因为 PageRoutes 有visit api 所以似乎是足够灵活来处理类似的路由框架?

@zjuwjf zjuwjf added the good first issue Good for newcomers label Jul 16, 2019
@tianlinzx
Copy link
Author

看了几个例子,总觉得fluro的 路由定义 final Router router = new Router();和 fish-redux 中的final AbstractRoutes routes = PageRoutes 是冲突的,两者只能取其一。因为最后都到了 onGenerateRoute 中。请问大佬,这里何解?请不吝赐教,困扰我有些天了。
@zjuwjf

@zjuwjf
Copy link
Contributor

zjuwjf commented Aug 2, 2019

PageRoutes 并不是必须的,你可以选择 fluro 来和Page 直接对接。

@tianlinzx
Copy link
Author

Thanks。这个用法我也见过。
但是如果这样,PageRoute里面visitor挂载全局状态 和那些middleware好像就挂载不了。
我主要咨询的点在这,这就是我说的两者只能选其一?

@zjuwjf
Copy link
Contributor

zjuwjf commented Aug 2, 2019

我并没有用过fluro,如果需要,可以提一个PR来改进下PageRoutes。

@tianlinzx
Copy link
Author

好的,研究一下fluro的代码先。

@kurloo
Copy link

kurloo commented Aug 18, 2019

不要用fish redux的router,可直接用fluro。fluro创建handler的时候直接返回**Page就可以。

@Yechenxing
Copy link

不要用fish redux的路由器,可直接用fluro.fluro创建handler's时候直接返回** Page就可以。

不可以,会报错**Page不是一个Widget

@zjuwjf
Copy link
Contributor

zjuwjf commented Sep 3, 2019

不要用fish redux的路由器,可直接用fluro.fluro创建handler's时候直接返回** Page就可以。

不可以,会报错**Page不是一个Widget

你使用 page.buildPage(options);

@zjuwjf zjuwjf added the the key issue the key issue label Sep 13, 2019
@zjuwjf
Copy link
Contributor

zjuwjf commented Sep 13, 2019

我想我会削弱fish-redux的路由的能力,将它退化为基础数据结构或api,方便于集成其他的路由框架。

也欢迎有同学能提供开源的fish_redux_fluro 类似的框架。

@codecomeon
Copy link

fluro基础上集成fish_redux,只需要在fluro的基础上route定义文件中将页面替换为page

/// 原来,pageA => StatefulWidget
router.define(pageARoute, handler: new Handler(
        handlerFunc: (BuildContext context, Map<String, List<String>> params) {
      return pageA();
    }));

/// 现在,pageA => Page - fish_redux的page
router.define(pageARoute, handler: new Handler(
        handlerFunc: (BuildContext context, Map<String, List<String>> params) {

     /// 选项 options
     /// 可以做pageStore与其他store的连接
     pageA.connectExtraStore(...)
     /// 可以做增强
     pageA.enhancer.append(...)

     return pageA.buildPage(options);
    }));

fish_redux基础上集成fluro,则是

/// fish_redux的路由全部分解到fluro中
PageRoutes(
    /// 路由定义
    page: ...
    /// 访问器
    visitor: ...
);

/// 1. 将路由定义改为fluro的router.define
/// 2. 将visitor的所有逻辑移到fluro的router.define(route, handler),handler当中
/// 3. 如果需要所有路由全部通用的逻辑,则自行封装

@codecomeon
Copy link

另外,提些建议:

  1. 作者没有必要实现pageRoutes,路由和状态管理不能混杂在一起。
  2. 可以加一个Page的全局配置,封装语法糖。
  3. 提供快速访问GlobalState的方式,减少代码量。

@zjuwjf
Copy link
Contributor

zjuwjf commented Oct 23, 2019

另外,提些建议:

  1. 作者没有必要实现pageRoutes,路由和状态管理不能混杂在一起。
  2. 可以加一个Page的全局配置,封装语法糖。
  3. 提供快速访问GlobalState的方式,减少代码量。

非常好的建议,设计原则上是一个小的错误。非常欢迎PR,一起来完善。

@adigest
Copy link

adigest commented Jan 7, 2020

好像不需要做其他的,
我在onGenerateRoute里加settings参数,就可以拿到路由、管理路由
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers the key issue the key issue
Projects
None yet
Development

No branches or pull requests

6 participants