onReceive(_:perform:)
Adds an action to perform when this view detects data emitted by the given publisher.
Declaration
nonisolated func onReceive<P>(_ publisher: P, perform action: @escaping (P.Output) -> Void) -> some View where P : Publisher, P.Failure == Never
Parameters
- publisher:
The publisher to subscribe to.
- action:
The action to perform when an event is emitted by
publisher. The event emitted by publisher is passed as a parameter toaction.
Return Value
A view that triggers action when publisher emits an event.