U vi @ sd d dl mZmZmZ ddlmZ ddlmZ ddlm Z ddl mZ edZG d d d ee Z dS ) )OptionalTypeVarcast )abc) Disposable )InnerSubscription)Subject_Tc sl e Zd ZdZedd fddZdeje eej ej dddZeddd d Zdd fdd Z ZS )BehaviorSubjectzRepresents a value that changes over time. Observers can subscribe to the subject to receive the last (or initial) value and all subsequent notifications. N)valuereturnc s t || _dS )a4 Initializes a new instance of the BehaviorSubject class which creates a subject that caches its last value and starts with the specified value. Args: value: Initial value sent to observers when no other value has been received by the subject yet. N)super__init__r )selfr __class__ R/opt/alt/python38/lib/python3.8/site-packages/reactivex/subject/behaviorsubject.pyr s zBehaviorSubject.__init__)observer schedulerr c C sr | j H | | jsD| j| || j t| |W 5 Q R S | j}W 5 Q R X |rd| | n| t S )N)lockZcheck_disposedZ is_stopped observersappendon_nextr r exceptionZon_errorZon_completedr )r r r exr r r _subscribe_core s zBehaviorSubject._subscribe_corec C s: | j | j }|| _W 5 Q R X |D ]}|| q&dS )z1Notifies all subscribed observers with the value.N)r r copyr r )r r r r r r r _on_next_core3 s zBehaviorSubject._on_next_core)r c s, | j ttd| _t W 5 Q R X dS )zRelease all resources. Releases all resources used by the current instance of the BehaviorSubject class and unsubscribe all observers. N)r r r r r dispose)r r r r r! <