Closed vakrilov closed 8 years ago
Issue opened in NativeScript repo: NativeScript/NativeScript#2229
Brilliant. Of course this makes sense! Thank you Alex. I'll merge this as it will fix this.
Wrapping observable.notify
is an interesting proposal there. This case I would consider user error as I should have known those callbacks needed to be in a zone callback and that sort of thing should be in the tips/tricks section of nativescript.org/angular as well as mentioned throughout the {N}+ng2 guide; I'll look into adding a section about that.
Fixes the problem when the search screen is not updated after login.
Problem
Callbacks for the Spotify plugin are not executed inside the zone so the change detection is not triggered on login.
Local Solution
Wrap all callbacks in a
ngZone.run()
Plugin Solution
There is
zonedCallback
method in the NativeScript modules that we use to wrap native callbacks (for examplesetTimeout()
). It will automatically execute the callback in the current zone (if there is a global Zone object). You can use that in the Spotify plugin to wrap all the event callbacks.NativeScript Core Solution
Consider wrapping all
Observable.notify()
calls inzonedCallback
. This might have performance implications though. I will open an issue for discussion in NativeScript repo