Exemple #1
0
def contains_(
    value: _T,
    comparer: Optional[typing.Comparer[_T]] = None
) -> Callable[[Observable[_T]], Observable[bool]]:
    comparer_ = comparer or default_comparer

    def predicate(v: _T) -> bool:
        return comparer_(v, value)

    return compose(
        ops.filter(predicate),
        ops.some(),
    )
Exemple #2
0
def all_(
        predicate: Predicate[_T]
) -> Callable[[Observable[_T]], Observable[bool]]:
    def filter(v: _T):
        return not predicate(v)

    def mapping(b: bool) -> bool:
        return not b

    return compose(
        ops.filter(filter),
        ops.some(),
        ops.map(mapping),
    )
Exemple #3
0
def is_empty_() -> Callable[[Observable[Any]], Observable[bool]]:
    """Determines whether an observable sequence is empty.

    Returns:
        An observable sequence containing a single element
        determining whether the source sequence is empty.
    """

    def mapper(b: bool) -> bool:
        return not b

    return compose(
        ops.some(),
        ops.map(mapper),
    )
Exemple #4
0
 def create():
     return xs.pipe(ops.some(lambda x: x > 0))
Exemple #5
0
 def create():
     return xs.pipe(ops.some())