Cancellable withObservationTracking in Swift
This function works as a one shot function and the
onChange
closure is called only once. Note that it is called before the value has actually changed. If we want to get the changed value, we would need to read the value on the next run loop cycle. It would be much more useful if we could use this function in a way where we could have an observation token and as long as it is set, the observation is active. Here is the function with cancellation support.[…]
The token closure controls if the change should be handled and if we need to continue tracking. Will and did change are closures called before and after the value has changed.
Previously:
Update (2024-09-18): See also: Marcin Krzyzanowski.
2 Comments RSS · Twitter · Mastodon
So I’m an astrophysicist, and I regularly trigger observations on an orbiting observatory called Swift. I was very confused for a good 30 seconds reading this entry and trying to figure out why Michael was suddenly needing UV data on celestial transients.
@Astro Guy
I am a graphics programmer, and I was very confused for a good minute on why you thought Michael needed UV-coordinate data for whatever.