Reputation: 339
I have two components that I want to sync an observable array between them. It works find with an observable, but with an array it never syncs. Can you syncWith
an observable array?
If I convert the array to string and then sync the observable it passes, but then I have to reconstruct the observable array on the other vm. Can it be done with just a syncWith
?
vm1
self.offers = ko.observableArray([]).syncWith("offersLink");
var mappedLogs = $.map(allData, function (item) { return new model.offerList(item) });
self.offers(mappedLogs);
vm2
self.offers = ko.observableArray([]).syncWith("offersLink");
Upvotes: 0
Views: 473
Reputation: 339
figured it out!
self.offers = ko.observableArray([]).syncWith("offersLink");
should be
self.offers = ko.observableArray().syncWith("offersLink");
[] was always overwriting with an empty array
Upvotes: 2