Observation Support #661
Replies: 3 comments 6 replies
|
The problem with We touch on this a bit at https://skip.dev/docs/app-development/#observables and you can see how we implement the fake "Observation" shim that makes this all work at https://github.com/skiptools/skip-android-bridge/blob/main/Sources/SkipAndroidBridge/Observation.swift. But in order to use this solution, the module needs to be "skip-aware", in that it imports the skip-fuse repository and the module must The best solution would be to figure out a way to properly hook into the Observation machinery to just support this out of the box, but the (rather weird) machinery of observation doesn't seem to have been designed with this scenario in mind. I'd be happy for other folk to take a look at it and verify this conclusion. We'd be doubly-happy if anyone can suggest a clean solution. 😉 For the time being, kludgy workaround might be to observe-the-observable at the View level, and then do something like update a local |
|
This also impacts the upcoming TCA26 (which now does compile for android 🙌 ) A simple feature like this does the same thing. On iOS, the changes are reflected in the view, but Android does not recompute its view to observe the changes when observation is emitted. Screen.Recording.2026-04-10.at.2.08.08.PM.movI know that @stephencelis and @mbrandonw have some pretty deep knowledge of Observation, (and a in depth series on it). Maybe they can help guide a true Observation implementation for skip I'm definitely interested in getting this working, and I think it's the whole cross platform story for TCA26+skip is looking achievable and very enticing as an app developer. 😃 |
|
I think we're in luck! My initial tests seem to show that true observation support should be straightforward! If I remember correctly, the SwiftUI internals just insert something similar to this on every view. I think that should be possible in the bridge or in skip-ui directly. I'll start excercising the WithObservationTracking wrapper against sharing and tca2. Theres prior art for this with https://github.com/pointfreeco/swift-perception. This same API on every view was needed to backport Observation to <iOS 17, back when it first came out. If this works under more thorough testing, you might be able to adopt it in skip-fuse and do away with the @observable bridge altogether |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Hey Team!
I'm diving into Android Support for the point-free tooling, including TCA 2.0, Sharing, and SqliteData
It's starting to be possible to compile a bunch of these libraries for Android, but I believe that Observation support is going to be a big hurdle.
Many of these libraries don't directly use the
@Observablemacro, but manually conform to theObservableprotocol. This works properly in SwiftUI, and when anObservableconforming type emits awithMutationnotification, it signals for a recomputation of any interested views.Sharing is the easiest to test this with, and the most trivial uses of
@Shareddon't work in skip.This compiles, but the view never re-renders after the mutation.
What needs to happen to migrate skip towards being able to handle these cases?
All reactions