Skip to content

Instantly share code, notes, and snippets.

@yimajo
Created August 4, 2020 10:45
Show Gist options
  • Save yimajo/d3c8f6b91261c1282b3eef77c8aeab15 to your computer and use it in GitHub Desktop.
Save yimajo/d3c8f6b91261c1282b3eef77c8aeab15 to your computer and use it in GitHub Desktop.
An idea to add an AccessToken to EnvironmentValues in the SwiftUI.
import SwiftUI
extension EnvironmentValues {
struct AccessTokenKey: EnvironmentKey {
static var defaultValue: String? {
nil
}
}
var accessToken: String? {
get {
self[AccessTokenKey.self]
}
set {
self[AccessTokenKey.self] = newValue
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment