diff --git a/Sources/Model/Data Flow/StateManager.swift b/Sources/Model/Data Flow/StateManager.swift index 147acb2..6550c00 100644 --- a/Sources/Model/Data Flow/StateManager.swift +++ b/Sources/Model/Data Flow/StateManager.swift @@ -12,8 +12,6 @@ public enum StateManager { /// Whether to block updates in general. public static var blockUpdates = false - /// The application identifier. - static var appID: String? /// The functions handling view updates. static var updateHandlers: [(Bool) -> Void] = [] diff --git a/Sources/Model/User Interface/App/App.swift b/Sources/Model/User Interface/App/App.swift index 976a2e4..da01ab1 100644 --- a/Sources/Model/User Interface/App/App.swift +++ b/Sources/Model/User Interface/App/App.swift @@ -26,14 +26,10 @@ public protocol App { /// The app storage type. associatedtype Storage: AppStorage - /// The app's application ID. - var id: String { get } /// The app's scene. @SceneBuilder var scene: Scene { get } - // swiftlint:disable implicitly_unwrapped_optional /// The app storage. - var app: Storage! { get set } - // swiftlint:enable implicitly_unwrapped_optional + var app: Storage { get set } /// An app has to have an `init()` initializer. init() @@ -58,8 +54,7 @@ extension App { /// /// To run the app, call the ``AppStorage/run(setup:)`` function. public static func setupApp() -> Self { - var appInstance = self.init() - appInstance.app = Storage(id: appInstance.id) + let appInstance = self.init() appInstance.app.storage.app = { appInstance } StateManager.addUpdateHandler { force in let updateProperties = force || appInstance.getState().contains { $0.value.content.update } @@ -77,7 +72,6 @@ extension App { appInstance.app.storage.sceneStorage.remove(at: index) } } - StateManager.appID = appInstance.id let state = appInstance.getState() appInstance.app.storage.stateStorage = state return appInstance diff --git a/Sources/Model/User Interface/App/AppStorage.swift b/Sources/Model/User Interface/App/AppStorage.swift index 3b8a6ce..25c5007 100644 --- a/Sources/Model/User Interface/App/AppStorage.swift +++ b/Sources/Model/User Interface/App/AppStorage.swift @@ -14,10 +14,6 @@ public protocol AppStorage: AnyObject { /// The scene storage. var storage: StandardAppStorage { get set } - /// Initialize the app storage. - /// - Parameters id: The app's identifier. - init(id: String) - /// Run the application. /// - Parameter setup: A closure that is expected to be executed right at the beginning. func run(setup: @escaping () -> Void) diff --git a/Tests/DemoApp/DemoApp.swift b/Tests/DemoApp/DemoApp.swift index 9471803..c18c87b 100644 --- a/Tests/DemoApp/DemoApp.swift +++ b/Tests/DemoApp/DemoApp.swift @@ -14,11 +14,10 @@ struct TestExecutable { struct DemoApp: App { - let id = "io.github.AparokshaUI.DemoApp" // #if os(...) - var app: Backend1.Backend1App! + var app = Backend1.Backend1App() // #else - // var app: Backend2.Backend2App! + // var app = Backend2.Backend2App() // #endif var scene: Scene { diff --git a/Tests/SampleBackends/Backend1.swift b/Tests/SampleBackends/Backend1.swift index a95d397..7de171e 100644 --- a/Tests/SampleBackends/Backend1.swift +++ b/Tests/SampleBackends/Backend1.swift @@ -156,7 +156,7 @@ public enum Backend1 { public var storage: StandardAppStorage = .init() - public required init(id: String) { } + public init() { } public func run(setup: @escaping () -> Void) { setup() diff --git a/Tests/SampleBackends/Backend2.swift b/Tests/SampleBackends/Backend2.swift index b5b276d..a025673 100644 --- a/Tests/SampleBackends/Backend2.swift +++ b/Tests/SampleBackends/Backend2.swift @@ -71,7 +71,7 @@ public enum Backend2 { public var storage: StandardAppStorage = .init() - public required init(id: String) { } + public required init() { } public func run(setup: @escaping () -> Void) { setup()