Attaches the specified subscriber to this publisher.
SDKs
- iOS 13.0+
- macOS 10.15+
- Mac Catalyst 13.0+
- tvOS 13.0+
- watchOS 6.0+
- Xcode 11.0+
Framework
- Combine
Declaration
func subscribe<S>(_ subscriber: S) where S : Subscriber, Self.Failure == S.Failure, Self.Output == S.Input
Parameters
subscriber
The subscriber to attach to this publisher. After attaching, the subscriber can start to receive values.
Discussion
Always call this function instead of receive(subscriber:)
. Adopters of Publisher
must implement receive(subscriber:)
. The implementation of subscribe(_:)
provided by Publisher
calls through to receive(subscriber:)
.