Closed jakeatoms closed 11 years ago
So, in this case you are not using the observable extensions, right? The subscribeTo
extension includes a boolean to populate using the latest published value (this.firstName = ko.observable().subscribeTo("myNameTopic", true);
).
If you are not using the extensions (just calling subscribe
), then you can still access the topicCache
off of the postbox object (ko.postbox
or if using AMD whatever you decided to call the variable).
For example, ko.postbox.topicCache.myTopic.value
will give you access to the last published value for the myTopic
topic. You could choose to use this value at the point where you subscribe,
That should work in the short term. Would you accept a pull request if I added additional arguments to subscribe
so that it matches subscribeTo
and if the value is true, it would invoke the given action (with topicCache[topic]
) after calling the ko subscribe function?
sure, yes that sounds reasonable.
ok, great! I'll work on that. I'm new to Git, so it will be good real world practice :)
This was completed in #17.
We're having an issue where our module that publishes on a topic is loaded and publishing before the module that subscribes is loaded. We'd like to be able to pass a boolean to postbox.subscribe indicating that it should initialize to the existing topic cache. Is that possible? Thanks!