The concat operator

The concat operator concatenates several observables. Each observable is concatenated to the previous one as soon as the previous observable completes. The following figure shows the marble diagram of this operator:

Figure 9.36: The concat operator

This operator can be used both as a class method and a static method. Its prototypes are the following ones:

Observable.concat(self, *args)
Observable.concat(cls, *args)

Here, args is either several observables to concatenate, or a list of observables.

Here is an example of the concat operator:

numbers1 = Observable.from_([1, 2, 3, 4])
numbers2 = Observable.from_([11, 12])

numbers1.concat(numbers2).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 example gives the following results:

on_next 1
on_next 2
on_next 3
on_next 4
on_next 11
on_next 12
on_completed
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.218.239.182