Closed bummoblizard closed 1 year ago
Extension API ideas:
While implementing these new features, explore the possibility of using generics in our APIs:
Example of using generics to abstract the common operations of extension contribution points (ToolBar, StatusBar etc.): https://github.com/thebaselab/codeapp/blob/main/CodeApp/Managers/ExtensionViewItemManager.swift
protocol CodeAppContributionPointManager: ObservableObject {
associatedtype Item where Item: Identifiable, Item.ID == UUID
var items: [Item] { get set }
func registerItem(item: Item)
func deregisterItem(id: UUID)
}
extension CodeAppContributionPointManager {
func registerItem(item: Item) {
items.append(item)
}
func deregisterItem(id: UUID) {
items.removeAll(where: { $0.id == id })
}
}
class StatusBarManager: CodeAppContributionPointManager {
@Published var items: [StatusBarItem] = []
}
class ToolbarManager: CodeAppContributionPointManager {
@Published var items: [ToolbarItem] = []
}
// .. etc
Plan:
This allows us to: