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.
|
|
|
import Vapor
|
|
|
|
|
|
|
|
// -----------------------------------------
|
|
|
|
|
|
|
|
public final class UserState: @unchecked Sendable {
|
|
|
|
var toast: ToastState = ToastState()
|
|
|
|
var todos: TodosState = TodosState()
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|