Observable.defer() takes a factory that takes Subscribable | PromiseLike. That is very annoying when the value is available synchronously and often results in a lot of boiler plate when usingconcat(). Simplified example:
const contents = new Map<string, string>();
getFilesInWorkspace()
.mergeMap(uri =>
// ensureContent emits no items, just completes once content is ensured
ensureContent(uri)
// After that, we can get the content synchronously
// Need Observable.of() here because just returning an array is not allowed
.concat(Observable.defer(() => Observable.of(contents.get(uri))))
)
.mergeMap(content => ...)