You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
657 B
33 lines
657 B
1 month ago
|
import Vapor
|
||
|
|
||
|
// -----------------------------------------
|
||
|
|
||
|
public final class UserState: @unchecked Sendable {
|
||
|
var toast: ToastState = ToastState()
|
||
|
}
|
||
|
|
||
|
// -----------------------------------------
|
||
|
|
||
|
struct UserStateKey: StorageKey {
|
||
|
typealias Value = UserState
|
||
|
}
|
||
|
|
||
|
struct UserStateManager: Sendable {
|
||
|
var states: [String: UserState] = [:]
|
||
|
}
|
||
|
|
||
|
struct UserStateManagerKey : StorageKey {
|
||
|
typealias Value = UserStateManager
|
||
|
}
|
||
|
|
||
|
extension Application {
|
||
|
var manager: UserStateManager {
|
||
|
get {
|
||
|
self.storage[UserStateManagerKey.self]!
|
||
|
}
|
||
|
set {
|
||
|
self.storage[UserStateManagerKey.self] = newValue
|
||
|
}
|
||
|
}
|
||
|
}
|