I'm currently switching from AngularJS to Angular and finding trouble moving from promises to observables. Here excerpt from my code in AngularJS.
var deferred = $q.defer(),
frame = document.createElement('newFrame');
/// some code here...
frame.onload = function () {
/// code..
deferred.resolve();
}
frame.onerror = function () {
/// code..
deferred.reject();
}
document.body.appendChild(frame);
return deferred.promise;
I could not find how to rewrite this code in Angular using observables. Looking through questions on StackOverflow I found this question, but here I don't use HTTP API, so it is harder to convert.
Is there any way around it?