This is almost what you want:
func withContinousObservation<T>(of value: @escaping @autoclosure () -> T, execute: @escaping (T) -> Void) {
withObservationTracking {
execute(value())
} onChange: {
DispatchQueue.main.async {
withContinousObservation(of: value(), execute: execute)
}
}
}
Ability of cancelling is missing in this implementation.