Combine Async Map
Reading time: 1 min
This quick recipe shows how to implement a Combine map operator that takes an async block. To do this, you need to:
- Use
Taskto run async code in a sync context. - Use the
Futurepublisher to publish the new value theTaskis completed. - Use
flatMapto transfer from your current publisher to theFutureone.
Reading time: 1 min
This quick recipe shows how to write an extension for a Combine Publisher whose output is of a generic type.
Timers and countdowns in SwiftUI
Reading time: 1 min
This recipe shows how to implement a timer in SwiftUI in order to update the UI state at a specific interval.
There are two ways of going about it:
- The simple one, with
onReceive. - A bit more complex, but also more powerful one, using
SimpleTimerwrapper.