knockout-postbox icon indicating copy to clipboard operation
knockout-postbox copied to clipboard

topicCache not cleared

Open marekburiak opened this issue 9 years ago • 1 comments

I have a knockout component which contains smaller components which use postbox for messaging. When I want to get rid of the component (and all the smaller ones) I call stopPublishingOn and unsubscribeFrom on all objects that are publishing on or are subscribed to a topic. After the cleanup there is no object that would be publishing on or subscribed to any topic used within that component. If I create a new instance of the same component, those smaller components get initialized with values from the previous component instance because the topicCache has not been cleared between disposing the old component and creating a new one. Not sure if it's an issue or just the way postbox works. Is there any way to remove the cached values other than manually removing specific topics and its values from postbox.topicCache?

marekburiak avatar Jun 19 '15 15:06 marekburiak

@marekburiak - there is not currently a way to do this without manipulating topicCache directly. The cache is saved so that the initializeWithLatestValue option works. It does make some sense that if all publishers/subscribers are gone it should clear the cache. I will leave this open until a fix is made.

rniemeyer avatar Aug 30 '15 02:08 rniemeyer