[Widgets]: Enhanced to isolate operations from multiple views of same widget type

This commit is contained in:
Magesh K
2025-01-11 03:25:25 +05:30
parent f69b293004
commit e29d9f7904
12 changed files with 346 additions and 245 deletions

View File

@@ -0,0 +1,30 @@
//
// SingletonGenericMap.swift
// SideStore
//
// Created by Magesh K on 10/01/25.
// Copyright © 2025 SideStore. All rights reserved.
//
class SingletonGenericMap{
static var shared = SingletonGenericMap()
private var pageInfoMap: [AnyHashable: Any] = [:]
private init() {}
func setPageInfo<T: Hashable, U>(for key: T, value: U?) {
pageInfoMap[key] = value
}
func getPageInfo<T: Hashable, U>(for key: T) -> U? {
return pageInfoMap[key] as? U
}
func popPageInfo<T: Hashable, U>(for key: T) -> U? {
return pageInfoMap.removeValue(forKey: key) as? U
}
func clearAll() {
pageInfoMap.removeAll()
}
}