-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
477 additions
and
254 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
Sources/Spezi/Capabilities/ApplicationPropertyWrapper.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// | ||
// This source file is part of the Stanford Spezi open-source project | ||
// | ||
// SPDX-FileCopyrightText: 2024 Stanford University and the project authors (see CONTRIBUTORS.md) | ||
// | ||
// SPDX-License-Identifier: MIT | ||
// | ||
|
||
|
||
@propertyWrapper | ||
public class _ApplicationPropertyWrapper<Value> { // swiftlint:disable:this type_name | ||
private let keyPath: KeyPath<Spezi, Value> | ||
|
||
private weak var spezi: Spezi? | ||
|
||
|
||
public var wrappedValue: Value { | ||
guard let spezi else { | ||
preconditionFailure("Underlying Spezi instance was not yet injected. @Application cannot be accessed within the initializer!") | ||
} | ||
return spezi[keyPath: keyPath] | ||
} | ||
|
||
public init(_ keyPath: KeyPath<Spezi, Value>) { | ||
self.keyPath = keyPath | ||
} | ||
} | ||
|
||
|
||
extension _ApplicationPropertyWrapper: SpeziPropertyWrapper { | ||
func inject(spezi: Spezi) { | ||
self.spezi = spezi | ||
} | ||
} | ||
|
||
|
||
extension Module { | ||
public typealias Application<Value> = _ApplicationPropertyWrapper<Value> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 0 additions & 46 deletions
46
Sources/Spezi/Capabilities/Lifecycle/Spezi+LifecycleHandlers.swift
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.