computed
computed copied to clipboard
fix: #83 修改behavior注入位置
如果behavior在头部注入会导致computed读不到mobx-bindings的数据。直接改成push好像也不太好,可能会覆盖其他用户自定义的behavior定义的数据?我的想法是在behaviors查找一次有没有注入mobxBehavior,但是我调试了一下发现behavior构造出来是一个字符串,所以我不知道怎么判断好,求大佬指点改进一下。 @TtTRz
感谢你的 PR,但这个 PR 会有如你所说的一些问题。
对于需要依赖 behavior 注入顺序的,可以考虑在 ComponentWithComputed 构造器里面加一个字段,用于在 computed behavior 之前插入自定义的 behavior。
比如
ComponentWithComputed({
behaviors: ["b", "c"],
behaviorsBeforeComputed: ["a"],
})
我试了一下没问题了,大佬麻烦看一下这样写行不行 @TtTRz