SwiftfulUI
SwiftfulUI copied to clipboard
Implemented 'OnAppFirstRun' View Modifier
Designed for initial app setup tasks, this modifier ensures code execution only on the app's first launch. It's ideal for one-time configurations.
I improved the code by adding FirstRunManager, a singleton, to manage one-time execution logic. This ensures that certain actions only run on the first app launch. We use a singleton for centralized state management, making the code more robust and preventing multiple executions, even across different views. The struct OnAppFirstRunModifier leverages this singleton to decide whether to execute its action, enhancing code reusability and clarity.
I think you misunderstood what I was referring to. This Singleton isn't adding any functionality from the original, I don't think?
With this modifier, the dev could add
HomeView()
.onAppFirstRun{
}
SecondView()
.onAppFirstRun{
}
... and many more times. Since it's a ViewModifer, it can be added to infinite amount of views. However, only the very first modifier will execute the action, which would seem like a bug to the developer.