Closed darrenhaken closed 9 years ago
@darrenhaken - this sounds like something that I could explore adding. do you typically use ko.postbox
directly or the observable extensions?
I've managed to work around this for now by doing the following in the tear down of the tests:
ko.postbox.H = {}
Can you see any problems with this?
The only issue is that H
will likely be minified to a different name in each build of Knockout, so it would not be the same between KO versions.
Hi Ryan,
I think it would be useful to have this feature built into the library then.
I'm happy to work on this with you if you would like me to?
Thanks,
Darren
On 29 May 2014 16:14, Ryan Niemeyer notifications@github.com wrote:
The only issue is that H will likely be minified to a different name in each build of Knockout, so it would not be the same between KO versions.
— Reply to this email directly or view it on GitHub https://github.com/rniemeyer/knockout-postbox/issues/25#issuecomment-44543074 .
@darrenhaken - if you have some time to try to implement it, then feel free to give it a shot and/or to use this thread to post ideas/questions/thoughts about it. Thanks!
This is incredibly important to me as well. My tests are failing constantly, and I have to arrange them differently for them to magically just work.
It is very critical.
@darrenhaken what is the H
variable called in the debug version of Postbox?
Oh, and furthermore, it also breaks my single-page design. If I use Pjax for single-page navigation, I would like to be able to clear my subscriptions when Pjax "navigates" to a new page without changing the URL.
I created a pull request which adds a unit test for this, and also a method to clear all variables. @rniemeyer could you check it out?
@ffMathy - Thanks! I'll take a look when I have a chance.
There is now a reset
method in v0.5.0
that will dispose all subscriptions related to ko.postbox
functionality.
Is it possible to clear subscriptions programatically?
I'm using Jasmine to write unit tests and I've noticed events seem to be firing in unexpected ways across tests. It would be good to clear all subscriptions as a clear up between tests as a guard to this.
I've seen another approach mentioned in an issue where they manually unsubscribe on each topic. However comes with risk as an unsubscribe could be missed, not to mention the overhead of managing each subscription.