SignalProtocol

protocol SignalProtocol : AnyObject
  • Make the Signal output optional Value.

    Declaration

    Swift

    public func promoteOptional() -> Signal<Value?, Error>
  • The original purpose of this method is to allow triggering animations in response to signal values.

    Example

    The following code

    self.constraint.reactive.constant <~ viewModel.constraintConstantValue.signal.observe(context: animatingContext)
    

    will result in all changes to constraintConstantValue in viewModel to be reflected in the constraint and animated.

    Declaration

    Swift

    public func observe(context: @escaping (@escaping () -> Void) -> Void) -> Signal<Value, Error>

    Parameters

    context

    Defines a context in which observers of the resulting signal will be called.

    Return Value

    A signal of which observers will receive values in the context defined by context function.

  • Applies transform to errors from the producer and forwards errors with non nil results unwrapped.

    Declaration

    Swift

    public func filterMapError<NewError: Swift.Error>(_ transform: @escaping (Error) -> NewError?) -> Signal<Value, NewError>

    Parameters

    transform

    A closure that accepts an error from the failed event and returns a new optional error.

    Return Value

    A producer that will send new errors, that are non nil after the transformation.

  • Returns a Signal which cannot fail. Errors that would be otherwise be sent in the original signal are ignored.

    Declaration

    Swift

    public func ignoreError() -> Signal<Value, NoError>
  • Converts a Signal that has a TransferState value into a Signal only returning a value when finished() is received.

    Declaration

    Swift

    public func ignoreLoading<Progress, Value>() -> Signal<Value, Error>
    	where Self.Value == TransferState<Progress, Value>
  • Maps a Signal for which each value is a TransferState into a TransferState returning the mapped value.

    Declaration

    Swift

    public func mapFinished<Progress, Value, Mapped>(_ mapper: @escaping (Value) -> Mapped) -> Signal<TransferState<Progress, Mapped>, Error>
    	where Self.Value == TransferState<Progress, Value>
  • Maps a Signal for which each value is a TransferState into a TransferState returning a SignalProducer returning the mapped value.

    Declaration

    Swift

    public func flatMapFinished<Progress, Value, Mapped>(_ mapper: @escaping (Value) -> SignalProducer<Mapped, Error>) -> Signal<TransferState<Progress, Mapped>, Error>
    	where Self.Value == TransferState<Progress, Value>