Closed neo-headz closed 10 years ago
@headz68 - postbox doesn't work directly with the notify
extender, but does support its own equality comparer option either globally or for anything extended with publishOn
. Your definition would look like:
myTopic = ko.observable(originalVal).publishOn('myTopic', function () { return true; }),
The function takes in the value to be published as an argument and returns true/false for whether to publish the value.
Hope that helps!
@rniemeyer thanks for the response! Unfortunately your suggestion did not work. I updated http://jsfiddle.net/headz68/Aw9B5/ I also tried using
myTopic = ko.observable(originalVal).publishOn('myTopic', false, function () { return true; }),
Nonetheless, I have a workaround in place but seems like there should be other experiencing this issue.
@headz68 - I guess that I had it a bit off. The equality comparer returns whether the new/prev values are equal. So, we would want to return false. Additionally, without the notify: always
the publish would never be attempted on primitive values that are the same. Would need to be like: http://jsfiddle.net/3H37j/ Sounds like you solved your issue, but I wanted to clarify.
@rniemeyer Thanks!
It would be nice if the published postbox observables had the ability to notify subscribers always, just like normal observables. See this fiddle: http://jsfiddle.net/headz68/Aw9B5/