Conditions | 5 |
Total Lines | 25 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | from typing import Optional |
||
8 | def rx_subject_from( |
||
9 | a_subject: Subject, |
||
10 | subscribe: Optional[Subscribe] = None, |
||
11 | on_next: Optional[NextHandler] = None, |
||
12 | on_error: Optional[ErrorHandler] = None, |
||
13 | on_completed: Optional[CompleteHandler] = None, |
||
14 | ) -> Subject: |
||
15 | """Build a subject from another one by override some function. |
||
16 | |||
17 | Args: |
||
18 | a_subject (Subject): the source subject |
||
19 | subscribe (Optional[Subscribe]): override subscribe if set |
||
20 | on_next (Optional[NextHandler]): override on_next if set |
||
21 | on_error (Optional[ErrorHandler]): override on_error if set |
||
22 | on_completed (Optional[CompleteHandler]): override on_completed if set |
||
23 | |||
24 | Returns; |
||
25 | (Subject): a new subject |
||
26 | |||
27 | """ |
||
28 | return subject( |
||
29 | subscribe=subscribe if subscribe else a_subject.subscribe, |
||
30 | on_next=on_next if on_next else a_subject.on_next, |
||
31 | on_error=on_error if on_error else a_subject.on_error, |
||
32 | on_completed=on_completed if on_completed else a_subject.on_completed, |
||
33 | ) |
||
34 |