RxJs Create Observable from resulting Promise
Use Rx.Observable.fromPromise(promise)
fromPromise:
Converts a Promises/A+ spec compliant Promise and/or ES2015 compliant Promise or a factory function which returns said Promise to an Observable sequence.
example:
var source = Rx.Observable.fromPromise(promise);var subscription = source.subscribe( function (x) { console.log('Next: %s', x); }, function (err) { console.log('Error: %s', err); }, function () { console.log('Completed'); });
update
rxjs6 method is from
I found the answer here (Just slightly differently named)rxjs using promise only once on subscribe
So for my example the answer is as simple as:
var loadCountries = function () { return $http.get('/countries'); };var observable = Rx.Observable.defer(loadCountries).shareReplay();