rniemeyer / knockout-postbox

A small library that uses Knockout's native pub/sub capabilities to facilitate decoupled communication between separate view models or components.
MIT License
350 stars 55 forks source link

Pub- Sub Issue #14

Closed techygarg closed 11 years ago

techygarg commented 11 years ago

Hi,

I am using Publisher and Subscriber with my Knockout models. I am facing problem to update run time generated observable array with Publisher and Subscriber.

Code Example :

In Parent Model self.Departments = ko.observableArray([]).publishOn("DepartmentList_" + transportId);

In Child Model

this.DepartmentList = ko.observableArray([]).subscribeTo("DepartmentList_" + transportId);

Parent Model contain one child model initially and pub-sub works fine, but if I add another child at run time,after apply bindings, (transportId is same for both childs), second child's DepartmentList does not update when Parent's Departments changes.

Basically pub-sub not working for items added after applyBindings.

It would be great if any body can put some light on it.

rniemeyer commented 11 years ago

So, how are you adding items to the Parent Model. Are you doing a push on self.Departments.

Can you maybe get an example in jsFiddle? Here is something to start with: http://jsfiddle.net/rniemeyer/XzU4t/

techygarg commented 11 years ago

Yes, I am using push to add items in parent model.

rniemeyer commented 11 years ago

@rahulgarg1985 - are you still having an issue? Can you recreate it in a fiddle and reopen this issue, if you are still seeing a problem? Thanks!