-
-
Notifications
You must be signed in to change notification settings - Fork 36
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
Saving State between launches #29
Comments
I love that idea! That would be really useful. I’ll think about how that would best be done. |
Do reckon we could possibly use My main reason for suggesting that is that it would solve the issue of having to figure out a good storage location for every different OS that SwiftCrossUI supports. Alternatively we could probably just find where |
And in terms of how to mark which properties are persistent, we could simplify that with something like this: protocol AppState: ViewState {
associatedtype PersistedState: Codable, ViewState
@Observed
var persisted: PersistedState
}
struct EmptyPersistedState: Codable {}
extension AppState where PersistedState == EmptyPersistedState {
@Observed
var persisted: EmptyPersistedState { EmptyPersistedState() }
} That means that if someone wants to persist part of their app state they can implement the I'm not sure if that code is actually valid, but it's at least close to what I have in mind, it may need some modification. |
GSettings sounds good!
I think currently @observed only works with value types and not reference types, which shouldn't be too hard to fix. |
Oh yeah, good catch. I can fix that pretty easily |
It would be nice to be able to save state between launches.
SavableAppState
that conforms to Codable orThe text was updated successfully, but these errors were encountered: