The start_with operator emits items on the output observable before any other item of the source observable. The marble diagram of this operator follows:
Figure 8.5: The start_with operator
The prototype of this operator is the following:
Observable.start_with(self, *args, **kw)
The args parameter contains the items to emit prior to any other one. Optionally, the first argument can be a scheduler. A scheduler can also be provided with the scheduler keyword argument.
The start_with operator can be used this way:
numbers = Observable.from_([1, 2, 3, 4])
numbers.start_with(0).subscribe(
on_next = lambda i: print("on_next {}".format(i)),
on_error = lambda e: print("on_error: {}".format(e)),
on_completed = lambda: print("on_completed")
)
This gives the following result: