What is the best way of cloning/copying an observablearray in knockoutJS?

后端 未结 4 760
终归单人心
终归单人心 2020-12-13 12:41

Question says it all really. I want to copy an observable array to another in KnockoutJS.

4条回答
  •  醉酒成梦
    2020-12-13 13:09

    Not exactly what you're asking, but I'd like to add this for posterity...

    If you want to clone an observable that stays in sync with the original (most often to create a throttled/debounced clone while maintaining the original), you can do something as such:

    const clone = ko.pureComputed(() => original()).extend({ rateLimit: 500 })

提交回复
热议问题