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

fix: #83 修改behavior注入位置 #84

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Wyatex
Copy link

@Wyatex Wyatex commented Jan 31, 2023

如果behavior在头部注入会导致computed读不到mobx-bindings的数据。直接改成push好像也不太好,可能会覆盖其他用户自定义的behavior定义的数据?我的想法是在behaviors查找一次有没有注入mobxBehavior,但是我调试了一下发现behavior构造出来是一个字符串,所以我不知道怎么判断好,求大佬指点改进一下。
@TtTRz

如果behavior在头部注入会导致computed读不到mobx-bindings的数据
@TtTRz
Copy link
Member

TtTRz commented Feb 3, 2023

感谢你的 PR,但这个 PR 会有如你所说的一些问题。

对于需要依赖 behavior 注入顺序的,可以考虑在 ComponentWithComputed 构造器里面加一个字段,用于在 computed behavior 之前插入自定义的 behavior。

比如

ComponentWithComputed({
    behaviors: ["b", "c"],
    behaviorsBeforeComputed: ["a"],
})

@Wyatex
Copy link
Author

Wyatex commented Feb 3, 2023

我试了一下没问题了,大佬麻烦看一下这样写行不行 @TtTRz

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

Successfully merging this pull request may close these issues.

2 participants