我的状态为BehaviorSubject<Array<user>>
(userListSub$
),可从不同位置更新.
例如,
- 当我在用户上单击跟随时
- 当我在用户上单击取消关注时
- 当我喜欢某个用户时
在不同的组件中订阅相同的状态.如果事件是在我喜欢用户时触发的,我希望特定组件不对状态(userListSub$
)发出的事件做出react .
I know we can store the origin of the event also in the state like this,
userListSub$.next({ data: user, origin: userList })
and check for the origin where I subscribe.
是否有更好的方法来标识或忽略特定订阅上的事件?
我的 idea 是正确的吗?如果没有,你能建议一个更好的方法吗?