I was under impression that Observable.[prototype.]concat
makes sure first operation is fully finished before second operation starts. But in following code:
The problem is that fromNodeCallback creates a function that when invoked executes the underlying function and returns the result of the invocation through an Observable
. Essentially the Observable
return value is replacing the node style callback you would normally have to pass as the last argument to the function. However, the function still gets invoked immediately.
If you want to delay the execution of the methods you can wrap them in defer
to prevent their execution until the Observables
are subscribed to.
var rimrafObservable = Observable.fromNodeCallback(rimraf);
var mkdirObservable = Observable.fromNodeCallback(mkdir);
Observable
.concat(
Observable.defer(() => rimrafObservable(path.resolve('./some_dir'))),
Observable.defer(() => mkdirObservable(path.resolve('./some_dir'))),
writeToSomeDir$
);