Back to Rxswift

PrimitiveSequence

docs/Structs/PrimitiveSequence.html

6.10.217.2 KB
Original Source

PrimitiveSequence

public struct PrimitiveSequence<Trait, Element>
extension PrimitiveSequence: PrimitiveSequenceType
extension PrimitiveSequence: ObservableConvertibleType

Observable sequences containing 0 or 1 element.

`

                primitiveSequence
                `

Declaration

Swift

public var primitiveSequence: PrimitiveSequence<Trait, Element> { get }

Return Value

Observable sequence that represents self.

`

                asObservable()
                `

Converts self to Observable sequence.

Declaration

Swift

public func asObservable() -> Observable<Element>

Return Value

Observable sequence that represents self.

`

                deferred(_:)
                `

Returns an observable sequence that invokes the specified factory function whenever a new observer subscribes.

Seealso

defer operator on reactivex.io

Declaration

Swift

static func deferred(_ observableFactory: @escaping () throws -> PrimitiveSequence<Trait, Element>)
    -> PrimitiveSequence<Trait, Element>

Parameters

| observableFactory |

Observable factory function to invoke for each observer that subscribes to the resulting sequence.

|

Return Value

An observable sequence whose observers trigger an invocation of the given observable factory function.

`

                delay(_:scheduler:)
                `

Returns an observable sequence by the source observable sequence shifted forward in time by a specified delay. Error events from the source observable sequence are not delayed.

Seealso

delay operator on reactivex.io

Declaration

Swift

func delay(_ dueTime: RxTimeInterval, scheduler: SchedulerType)
    -> PrimitiveSequence<Trait, Element>

Parameters

| dueTime |

Relative time shift of the source by.

| | scheduler |

Scheduler to run the subscription delay timer on.

|

Return Value

the source Observable shifted in time by the specified delay.

`

                delaySubscription(_:scheduler:)
                `

Time shifts the observable sequence by delaying the subscription with the specified relative time duration, using the specified scheduler to run timers.

Seealso

delay operator on reactivex.io

Declaration

Swift

func delaySubscription(_ dueTime: RxTimeInterval, scheduler: SchedulerType)
    -> PrimitiveSequence<Trait, Element>

Parameters

| dueTime |

Relative time shift of the subscription.

| | scheduler |

Scheduler to run the subscription delay timer on.

|

Return Value

Time-shifted sequence.

`

                observe(on:)
                `

Wraps the source sequence in order to run its observer callbacks on the specified scheduler.

This only invokes observer callbacks on a scheduler. In case the subscription and/or unsubscription actions have side-effects that require to be run on a scheduler, use subscribeOn.

Seealso

observeOn operator on reactivex.io

Declaration

Swift

func observe(on scheduler: ImmediateSchedulerType)
    -> PrimitiveSequence<Trait, Element>

Parameters

| scheduler |

Scheduler to notify observers on.

|

Return Value

The source sequence whose observations happen on the specified scheduler.

`

                observeOn(_:)
                `

Wraps the source sequence in order to run its observer callbacks on the specified scheduler.

This only invokes observer callbacks on a scheduler. In case the subscription and/or unsubscription actions have side-effects that require to be run on a scheduler, use subscribeOn.

Seealso

observeOn operator on reactivex.io

Declaration

Swift

@available(*, deprecated, renamed: "observe(on:﹚")
func observeOn(_ scheduler: ImmediateSchedulerType)
    -> PrimitiveSequence<Trait, Element>

Parameters

| scheduler |

Scheduler to notify observers on.

|

Return Value

The source sequence whose observations happen on the specified scheduler.

`

                subscribe(on:)
                `

Wraps the source sequence in order to run its subscription and unsubscription logic on the specified scheduler.

This operation is not commonly used.

This only performs the side-effects of subscription and unsubscription on the specified scheduler.

In order to invoke observer callbacks on a scheduler, use observeOn.

Seealso

subscribeOn operator on reactivex.io

Declaration

Swift

func subscribe(on scheduler: ImmediateSchedulerType)
    -> PrimitiveSequence<Trait, Element>

Parameters

| scheduler |

Scheduler to perform subscription and unsubscription actions on.

|

Return Value

The source sequence whose subscriptions and unsubscriptions happen on the specified scheduler.

`

                subscribeOn(_:)
                `

Wraps the source sequence in order to run its subscription and unsubscription logic on the specified scheduler.

This operation is not commonly used.

This only performs the side-effects of subscription and unsubscription on the specified scheduler.

In order to invoke observer callbacks on a scheduler, use observeOn.

Seealso

subscribeOn operator on reactivex.io

Declaration

Swift

@available(*, deprecated, renamed: "subscribe(on:﹚")
func subscribeOn(_ scheduler: ImmediateSchedulerType)
    -> PrimitiveSequence<Trait, Element>

Parameters

| scheduler |

Scheduler to perform subscription and unsubscription actions on.

|

Return Value

The source sequence whose subscriptions and unsubscriptions happen on the specified scheduler.

`

                catchError(_:)
                `

Continues an observable sequence that is terminated by an error with the observable sequence produced by the handler.

Seealso

catch operator on reactivex.io

Declaration

Swift

@available(*, deprecated, renamed: "catch(_:﹚")
func catchError(_ handler: @escaping (Swift.Error) throws -> PrimitiveSequence<Trait, Element>)
    -> PrimitiveSequence<Trait, Element>

Parameters

| handler |

Error handler function, producing another observable sequence.

|

Return Value

An observable sequence containing the source sequence’s elements, followed by the elements produced by the handler’s resulting observable sequence in case an error occurred.

`

                catch(_:)
                `

Continues an observable sequence that is terminated by an error with the observable sequence produced by the handler.

Seealso

catch operator on reactivex.io

Declaration

Swift

func `catch`(_ handler: @escaping (Swift.Error) throws -> PrimitiveSequence<Trait, Element>)
    -> PrimitiveSequence<Trait, Element>

Parameters

| handler |

Error handler function, producing another observable sequence.

|

Return Value

An observable sequence containing the source sequence’s elements, followed by the elements produced by the handler’s resulting observable sequence in case an error occurred.

`

                retry(_:)
                `

If the initial subscription to the observable sequence emits an error event, try repeating it up to the specified number of attempts (inclusive of the initial attempt) or until is succeeds. For example, if you want to retry a sequence once upon failure, you should use retry(2) (once for the initial attempt, and once for the retry).

Seealso

retry operator on reactivex.io

Declaration

Swift

func retry(_ maxAttemptCount: Int)
    -> PrimitiveSequence<Trait, Element>

Parameters

| maxAttemptCount |

Maximum number of times to attempt the sequence subscription.

|

Return Value

An observable sequence producing the elements of the given sequence repeatedly until it terminates successfully.

`

                retry(when:)
                `

Repeats the source observable sequence on error when the notifier emits a next value. If the source observable errors and the notifier completes, it will complete the source sequence.

Seealso

retry operator on reactivex.io

Declaration

Swift

func retry<Error: Swift.Error>(when notificationHandler: @escaping (Observable<Error>) -> some ObservableType)
    -> PrimitiveSequence<Trait, Element>

Parameters

| notificationHandler |

A handler that is passed an observable sequence of errors raised by the source observable and returns and observable that either continues, completes or errors. This behavior is then applied to the source observable.

|

Return Value

An observable sequence producing the elements of the given sequence repeatedly until it terminates successfully or is notified to error or complete.

`

                retryWhen(_:)
                `

Repeats the source observable sequence on error when the notifier emits a next value. If the source observable errors and the notifier completes, it will complete the source sequence.

Seealso

retry operator on reactivex.io

Declaration

Swift

@available(*, deprecated, renamed: "retry(when:﹚")
func retryWhen<Error: Swift.Error>(_ notificationHandler: @escaping (Observable<Error>) -> some ObservableType)
    -> PrimitiveSequence<Trait, Element>

Parameters

| notificationHandler |

A handler that is passed an observable sequence of errors raised by the source observable and returns and observable that either continues, completes or errors. This behavior is then applied to the source observable.

|

Return Value

An observable sequence producing the elements of the given sequence repeatedly until it terminates successfully or is notified to error or complete.

`

                retry(when:)
                `

Repeats the source observable sequence on error when the notifier emits a next value. If the source observable errors and the notifier completes, it will complete the source sequence.

Seealso

retry operator on reactivex.io

Declaration

Swift

func retry(when notificationHandler: @escaping (Observable<Swift.Error>) -> some ObservableType)
    -> PrimitiveSequence<Trait, Element>

Parameters

| notificationHandler |

A handler that is passed an observable sequence of errors raised by the source observable and returns and observable that either continues, completes or errors. This behavior is then applied to the source observable.

|

Return Value

An observable sequence producing the elements of the given sequence repeatedly until it terminates successfully or is notified to error or complete.

`

                retryWhen(_:)
                `

Repeats the source observable sequence on error when the notifier emits a next value. If the source observable errors and the notifier completes, it will complete the source sequence.

Seealso

retry operator on reactivex.io

Declaration

Swift

@available(*, deprecated, renamed: "retry(when:﹚")
func retryWhen(_ notificationHandler: @escaping (Observable<Swift.Error>) -> some ObservableType)
    -> PrimitiveSequence<Trait, Element>

Parameters

| notificationHandler |

A handler that is passed an observable sequence of errors raised by the source observable and returns and observable that either continues, completes or errors. This behavior is then applied to the source observable.

|

Return Value

An observable sequence producing the elements of the given sequence repeatedly until it terminates successfully or is notified to error or complete.

`

                debug(_:trimOutput:file:line:function:)
                `

Prints received events for all observers on standard output.

Seealso

do operator on reactivex.io

Declaration

Swift

func debug(_ identifier: String? = nil, trimOutput: Bool = false, file: String = #file, line: UInt = #line, function: String = #function)
    -> PrimitiveSequence<Trait, Element>

Parameters

| identifier |

Identifier that is printed together with event description to standard output.

| | trimOutput |

Should output be trimmed to max 40 characters.

|

Return Value

An observable sequence whose events are printed to standard output.

`

                using(_:primitiveSequenceFactory:)
                `

Constructs an observable sequence that depends on a resource object, whose lifetime is tied to the resulting observable sequence’s lifetime.

Seealso

using operator on reactivex.io

Declaration

Swift

static func using<Resource: Disposable>(_ resourceFactory: @escaping () throws -> Resource, primitiveSequenceFactory: @escaping (Resource) throws -> PrimitiveSequence<Trait, Element>)
    -> PrimitiveSequence<Trait, Element>

Parameters

| resourceFactory |

Factory function to obtain a resource object.

| | primitiveSequenceFactory |

Factory function to obtain an observable sequence that depends on the obtained resource.

|

Return Value

An observable sequence whose lifetime controls the lifetime of the dependent resource object.

`

                timeout(_:scheduler:)
                `

Applies a timeout policy for each element in the observable sequence. If the next element isn’t received within the specified timeout duration starting from its predecessor, a TimeoutError is propagated to the observer.

Seealso

timeout operator on reactivex.io

Declaration

Swift

func timeout(_ dueTime: RxTimeInterval, scheduler: SchedulerType)
    -> PrimitiveSequence<Trait, Element>

Parameters

| dueTime |

Maximum duration between values before a timeout occurs.

| | scheduler |

Scheduler to run the timeout timer on.

|

Return Value

An observable sequence with a RxError.timeout in case of a timeout.

`

                timeout(_:other:scheduler:)
                `

Applies a timeout policy for each element in the observable sequence, using the specified scheduler to run timeout timers. If the next element isn’t received within the specified timeout duration starting from its predecessor, the other observable sequence is used to produce future messages from that point on.

Seealso

timeout operator on reactivex.io

Declaration

Swift

func timeout(
    _ dueTime: RxTimeInterval,
    other: PrimitiveSequence<Trait, Element>,
    scheduler: SchedulerType
) -> PrimitiveSequence<Trait, Element>

Parameters

| dueTime |

Maximum duration between values before a timeout occurs.

| | other |

Sequence to return in case of a timeout.

| | scheduler |

Scheduler to run the timeout timer on.

|

Return Value

The source sequence switching to the other sequence in case of a timeout.