ValidatedSubject

public class ValidatedSubject<T, S> : Subject where T == S.Output, S : Subject, S.Failure == Never

ValidatedSubject

A base class that can be used to wrap any Subject type and sends validated objects to downstream subscribers.

  • The output type.

    Declaration

    Swift

    public typealias Output = T
  • The failure type.

    Declaration

    Swift

    public typealias Failure = Never
  • The validator used to validate objects before sending them to downstream subscribers.

    Declaration

    Swift

    public let validator: Validator<T>
  • Initializes a new instance.

    Declaration

    Swift

    public init(validator: Validator<T>, subject: S)

    Parameters

    validator

    The validator to use to validate objects.

    subject

    The Subject type we are wrapping.

  • Validates the value before sending it to downstream subscribers.

    See also

    Subject

    Declaration

    Swift

    public func send(_ value: T)

    Parameters

    value

    The value to validate before sendiing downstream.

  • Signals a completion.

    See also

    Subject

    Declaration

    Swift

    public func send(completion: Subscribers.Completion<Failure>)
  • Attaches a new subscription.

    See also

    Subject

    Declaration

    Swift

    public func send(subscription: Subscription)
  • Attaches a new subscriber.

    See also

    Subject

    Declaration

    Swift

    public func receive<S>(subscriber: S) where S : Subscriber, S.Output == S.Input, S.Failure == ValidatedSubject<T, S>.Failure