U vi@sddlmZddlmZmZmZmZmZmZddl mZmZddl m Z ddl m Z ddlmZedZGd d d eeZGd d d eeZGd ddeeZGdddeeZeeegdfeedddZdS))abstractmethod)AnyCallableGenericOptionalTypeVarUnion)abctyping)ImmediateScheduler) Observable)Observer_Tc@seZdZdZddddZdeejee j efe ej e ej ddddZeejee ej e ej ddd d Zee j edd d d Zde e je jedddZdedddZeedddZdS) Notificationz)Represents a notification to an observer.NreturncCsd|_|d|_dS)z*Default constructor used by derived types.FN) has_valuekindselfrG/opt/alt/python38/lib/python3.8/site-packages/reactivex/notification.py__init__szNotification.__init__on_nexton_error on_completedrcCs$t|tjr||S||||S)aSInvokes the delegate corresponding to the notification or an observer and returns the produced result. Examples: >>> notification.accept(observer) >>> notification.accept(on_next, on_error, on_completed) Args: on_next: Delegate to invoke for an OnNext notification. on_error: [Optional] Delegate to invoke for an OnError notification. on_completed: [Optional] Delegate to invoke for an OnCompleted notification. Returns: Result produced by the observation.) isinstancer ObserverBase_accept_observer_acceptrrrrrrraccepts  zNotification.acceptcCstdSNNotImplementedErrorr#rrrr"2szNotification._acceptobserverrcCstdSr%r&rr)rrrr!;szNotification._accept_observer) schedulerrcs<|p tdtjtttjtjdfdd }t|S)a}Returns an observable sequence with a single notification, using the specified scheduler, else the immediate scheduler. Args: scheduler: [Optional] Scheduler to send out the notification calls on. Returns: An observable sequence that surfaces the behavior of the notification upon subscription. N)r)r+rcs,tjtddfdd }|p }||S)N)r+statercs jdkrdS)NN)r!rr)r+r,)r)rrractionTs  z=Notification.to_observable..subscribe..action)r SchedulerBaserZschedule)r)r+r.Z_Notification__schedulerZ _schedulerr)r)r subscribePsz-Notification.to_observable..subscribe)N) r Z singletonr r rrr/ZDisposableBaser )rr+r1rr0r to_observable?s  zNotification.to_observablezNotification[_T])otherrcCs|sdnt|}t||kS)zIIndicates whether this instance and a specified object are equal.r)str)rr3Z other_stringrrrequals^szNotification.equalscCs ||Sr%)r5)rr3rrr__eq__eszNotification.__eq__)NN)N)__name__ __module__ __qualname____doc__rrr OnNextrr r rOnError OnCompletedr$rr"r!r/ZObservableBaser2boolr5rr6rrrrr s2   rcsteZdZdZeddfdd Zdejeeej eej ddddZ e j edd d d Zed d dZZS)r;z1Represents an OnNext notification to an observer.Nvaluercs$tt|||_d|_d|_dS)z)Constructs a notification of a new value.Tr-N)superr;rr@rr)rr@ __class__rrrlszOnNext.__init__rcCs ||jSr%r@r#rrrr"tszOnNext._acceptr(cCs ||jSr%)rr@r*rrrr!|szOnNext._accept_observerrcCs$|j}t|trt|}dt|S)Nz OnNext(%s))r@rintfloatr4)rvalrrr__str__s zOnNext.__str__)NN)r7r8r9r:rrr r;rr<r=r"r r r!r4rH __classcell__rrrBrr;is  r;cszeZdZdZeeefddfdd Zej e e ej e ej ddddZeje dd d d Zed d dZZS)r<z2Represents an OnError notification to an observer.Nerrorrcs0tt|t|tr|nt||_d|_dS)z*Constructs a notification of an exception.EN)rAr<rr Exception exceptionr)rrKrBrrrszOnError.__init__rcCs|r||jSdSr%)rNr#rrrr"szOnError._acceptr(cCs ||jSr%)rrNr*rrrr!szOnError._accept_observerrcCsdt|jS)Nz OnError(%s))r4rNrrrrrHszOnError.__str__)r7r8r9r:rrMr4rr r;rrr<r=r"r r r!rHrIrrrBrr<s  r<cspeZdZdZddfdd Zejeeej eej ddddZ e j edd d d Zedd d ZZS)r=z6Represents an OnCompleted notification to an observer.Nrcstt|d|_dS)z3Constructs a notification of the end of a sequence.CN)rAr=rrrrBrrrszOnCompleted.__init__rcCs|r |SdSr%rr#rrrr"szOnCompleted._acceptr(cCs|Sr%)rr*rrrr!szOnCompleted._accept_observercCsdS)Nz OnCompleted()rrrrrrHszOnCompleted.__str__)r7r8r9r:rr r;rrr<r=r"r r r!r4rHrIrrrBrr=s r=N)handlerrcsFtddfdd }tddfdd }ddfd d }t|||S) a Creates an observer from a notification callback. Args: handler: Action that handles a notification. Returns: The observer object that invokes the specified handler using a notification corresponding to each message it receives. Nr?cs t|Sr%)r;rDrPrr_on_nextszfrom_notifier.._on_nextrJcs t|Sr%)r<)rKrQrr _on_errorsz from_notifier.._on_errorrcs tSr%)r=rrQrr _on_completedsz$from_notifier.._on_completed)rrMr)rPrRrSrTrrQr from_notifiers rU)r rr rrrrrrZ reactivexZreactivex.schedulerr Z observabler r)rrrr;r<r=rUrrrrs     \