-
-
Notifications
You must be signed in to change notification settings - Fork 112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add SwiftUI App Lifecycle #195
Conversation
This comment has been minimized.
This comment has been minimized.
private enum ScenePhaseObserver { | ||
static var publisher = CurrentValueSubject<ScenePhase, Never>(.active) | ||
|
||
static func observe() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another cue to look for here is document.hasFocus()
— if it’s false
but document.visiblityState
is visible
, the page is .inactive
. I couldn’t find out if there were any events that trigger when this changes, though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't seem like it looking through MDN. If you find something lmk.
Turns out this requires latest |
Is there anything in the lifecycle API that isn't covered by this PR? I'm just wondering if this should be added to the progress document |
Custom scenes are not yet supported. We could support these in a future PR IMO: struct TokamakDemoScene : Scene {
var body: some Scene {
WindowGroup { ... }
}
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fantastic! 👏
This PR adds the
App
protocol, as well asScene
s, modifiers, and changes to the renderer to make building apps entirely with Tokamak simpler:I've also implemented
@AppStorage
and@SceneStorage
with the ability for renderers to override the default containers:AppStorage
will automatically update all tabs when one changes the value.SceneStorage
will automatically be loaded on page-load as well as when anyView
in the app updates it.TokamakDOM
useslocalStorage
andsessionStorage
.This PR also contains the
ScenePhase
environment value:.active
: Tab is active in the window of the browser..background
: Tab is open, but not active.This automatically updates with the
PageVisibility API
.