mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-03-22 01:19:16 +01:00
swiftUI support done for now
This commit is contained in:
45
Sources/EnvironmentKeys.swift
Normal file
45
Sources/EnvironmentKeys.swift
Normal file
@@ -0,0 +1,45 @@
|
||||
//
|
||||
// EnvironmentKeys.swift
|
||||
// CoreStore
|
||||
//
|
||||
// Created by John Rommel Estropia on 2019/10/05.
|
||||
// Copyright © 2019 John Rommel Estropia. All rights reserved.
|
||||
//
|
||||
|
||||
#if canImport(SwiftUI)
|
||||
|
||||
import SwiftUI
|
||||
|
||||
|
||||
// MARK: - DataStackEnvironmentKey
|
||||
|
||||
@available(iOS 13.0, tvOS 13.0, watchOS 6.0, macOS 15.0, *)
|
||||
public struct DataStackEnvironmentKey: EnvironmentKey {
|
||||
|
||||
// MARK: Public
|
||||
|
||||
public static var defaultValue: DataStack {
|
||||
|
||||
return Shared.defaultStack
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: - EnvironmentValues
|
||||
|
||||
@available(iOS 13.0, tvOS 13.0, watchOS 6.0, macOS 15.0, *)
|
||||
extension EnvironmentValues {
|
||||
|
||||
// MARK: Public
|
||||
|
||||
public var dataStack: DataStack {
|
||||
get {
|
||||
return self[DataStackEnvironmentKey.self]
|
||||
}
|
||||
set {
|
||||
self[DataStackEnvironmentKey.self] = newValue
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user