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

关于监听器(listener)摆放位置的请教 #46

Closed
guopeng1994 opened this issue Mar 8, 2019 · 1 comment
Closed

关于监听器(listener)摆放位置的请教 #46

guopeng1994 opened this issue Mar 8, 2019 · 1 comment

Comments

@guopeng1994
Copy link

来自flutter小白的请教:
如果需要添加类似下面这种监听器
focusNode.addListener((){
if(focusNode.hasFocus){
// do something or dispatch some action
} else {
// other things or dispatch other action
}
})

那么应该在什么哪个位置添加?如果在State中声明focusNode 并初始化, 那么addListener也应该在这个时候就添加了么?但是如果在这个时候添加的话,那么监听器处理函数里面又怎么去dispatch相关的action来另外处理呢?

@zjuwjf
Copy link
Contributor

zjuwjf commented Mar 8, 2019

我愿意将这类非响应式的事件源和action的绑定过程放在effect的initState。

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

2 participants