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

是否可以开放个接口,在new dva()的时候,给effect第二参数加入其他的属性 #48

Closed
Manweill opened this issue Aug 26, 2016 · 9 comments

Comments

@Manweill
Copy link

Manweill commented Aug 26, 2016

是否可以开放个接口,在new dva()的时候,给effects 第二参数加入其他的属性

例如 history给传进去。

好吧,其实我只是想要effects可以调用history.push做跳转~

@sorrycc
Copy link
Member

sorrycc commented Aug 26, 2016

import { routerRedux } from 'dva/router';

然后在 effects 里:

yield put(routerRedux.push('/app'));

@helloyou2012
Copy link
Contributor

其实可以像 choo 一样把 history 的接口内置:https://github.com/yoshuawuyts/choo/blob/master/index.js#L148

@sorrycc
Copy link
Member

sorrycc commented Aug 26, 2016

@helloyou2012 看实现,choo 里内置了 location:setLocation 的 reducer,和我们通过 routerRedux 的操作并没有太大区别吧。

@helloyou2012
Copy link
Contributor

恩,不过这样不用每次都 import routerRedux ,直接 put 就可以了

@sorrycc
Copy link
Member

sorrycc commented Aug 26, 2016

被你一说还真觉得有点麻烦,1.0 之后我想想怎么简化。

@nikogu
Copy link
Member

nikogu commented Aug 26, 2016

import { routerRedux } from 'dva/router'; 这种其实更直观,感觉对熟悉 redux 的人更友好,如果像 choo 一样内置了,感觉有点凌乱

@Manweill
Copy link
Author

我就是觉得每次都要导进去有点麻烦。所以才这么问的,然而文字表达有问题 O__O "…

@wenzhihong2003
Copy link

同意 @nikogu 的说法,

import { routerRedux } from 'dva/router'; 

这样更加的直观, 太高程度的封装, 反而让人不知道来源了.

@longzb
Copy link

longzb commented Oct 1, 2016

@manwei-lww 我喜欢每次都导。反正也不麻烦。

@sorrycc sorrycc closed this as completed Sep 2, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants