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

为什么不增加一个 watch API 呢 #36

Open
proc07 opened this issue Apr 28, 2019 · 7 comments
Open

为什么不增加一个 watch API 呢 #36

proc07 opened this issue Apr 28, 2019 · 7 comments

Comments

@proc07
Copy link

proc07 commented Apr 28, 2019

是否考虑下!

@imyelo
Copy link
Member

imyelo commented Apr 28, 2019

Component properties 可以先用 observe 满足,其他场景确实需要 watch API,欢迎 PR ~

@proc07
Copy link
Author

proc07 commented May 15, 2019

@imyelo 我现在在做一个国际化插件,实现过程是:在 Page Componen 函数(或者wx)下增加一个 lang 属性,在每个 page 页面或者是 component 组件下,进行 watch 监听该属性,在变化时,进行更新 data 数据。

@proc07
Copy link
Author

proc07 commented May 15, 2019

我现在自己用 Object.defineProperty 手写了个先用 😂

@imyelo
Copy link
Member

imyelo commented May 17, 2019

Component 现在兼容了 observers 接口 #40 ,对在组件中监听数据的场景有帮助 😄

@proc07
Copy link
Author

proc07 commented May 17, 2019

@imyelo 好的谢谢,但是我觉的 Component 组件数据字段监听器,用于监听 properties 和 data 的变化,好像不能对全局变量进行监听比如 app.globaldata wx.[xxx]这样的,还有就是 page 下,希望能考虑支持下。

@imyelo
Copy link
Member

imyelo commented May 17, 2019

@imyelo 好的谢谢,但是我觉的 Component 组件数据字段监听器,用于监听 properties 和 data 的变化,好像不能对全局变量进行监听比如 app.globaldata wx.[xxx]这样的,还有就是 page 下,希望能考虑支持下。

是的,Page 还没能支持;全局变量的话可能更适合用 flux 的模式 (例如 redux) 🤔

@hoboy0313
Copy link

watch 还是有场景需要的说,特意来看看。

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

3 participants