Whats the best way of linking/synchronising view models in Knockout?

后端 未结 4 1242
时光取名叫无心
时光取名叫无心 2020-12-08 03:07

If you have several view models on one page, how do you ensure that you can keep them synced? For example, if one item is added or a button clicked on one view model and you

4条回答
  •  醉酒成梦
    2020-12-08 04:08

    You seem to be driving toward contradictory goals. The way you would do that in Knockout is to create observables, but yet you don't seem to want that.

    If you have Foo and Bar objects with observables, you may not want observables on Foo that interact with bar or vice-verse, but why not have a Widget that watches Foo and Bar and mediates?

提交回复
热议问题