U vi @sddlmZmZmZmZddlmZmZmZddlm Z ddl m Z ddl mZedZdeeeeeegeefd d d Zdeeeeeeeegeefd d dZdd gZdS))CallableOptionalTypeVarcast) Observableabccompose) operators)SequenceContainsNoElementsError) Predicate_TFN) has_default default_valuereturncs"ttttdfdd }|S)N)sourcercs.dtjtttjdfdd }t|S)N)observer schedulercs6tdfdd }fdd}j|j||dS)Nxcs|dSN)on_next on_completedrrT/opt/alt/python38/lib/python3.8/site-packages/reactivex/operators/_firstordefault.pyrs z[first_or_default_async_..first_or_default_async..subscribe..on_nextcs.stnttdSr)on_errorr rrr rr)rr rrrrsz`first_or_default_async_..first_or_default_async..subscribe..on_completed)r)r subscriber)rrrr)rr rrrrszJfirst_or_default_async_..first_or_default_async..subscribe)N)rZ ObserverBaser rZ SchedulerBaser)rrrr )rrfirst_or_default_asyncs z7first_or_default_async_..first_or_default_async)rr )r rrrrrfirst_or_default_async_ sr) predicaterrcCs&|rtt|td|Std|S)aReturns the first element of an observable sequence that satisfies the condition in the predicate, or a default value if no such element exists. Examples: >>> res = source.first_or_default() >>> res = source.first_or_default(lambda x: x > 3) >>> res = source.first_or_default(lambda x: x > 3, 0) >>> res = source.first_or_default(None, 0) Args: source -- Observable sequence. predicate -- [optional] A predicate function to evaluate for elements in the source sequence. default_value -- [Optional] The default value if no such element exists. If not specified, defaults to None. Returns: A function that takes an observable source and reutrn an observable sequence containing the first element in the observable sequence that satisfies the condition in the predicate, or a default value if no such element exists. NT)ropsfilterZfirst_or_defaultr)r rrrrfirst_or_default_'sr#)FN)NN)typingrrrrZ reactivexrrrr r!Zreactivex.internal.exceptionsr Zreactivex.typingr r boolrr#__all__rrrrs(