feat: refactor1

This commit is contained in:
2025-05-23 15:30:48 +02:00
parent 33d8306f22
commit 0cb9387492
3 changed files with 8 additions and 8 deletions

View File

@@ -2,20 +2,20 @@ pub const UnknownTabError = error.UnknownTab;
pub const AppState = struct {
currentTab: *Tab = undefined,
tabs: std.ArrayList(Tab),
tabs: std.ArrayList(*Tab),
currentTabChanged: Observable(*Tab),
tabPreCurrentItemsUnload: Observable(*Tab),
pub fn init(allocator: std.mem.Allocator) AppState {
return .{
.tabs = std.ArrayList(Tab).init(allocator),
.tabs = std.ArrayList(*Tab).init(allocator),
.currentTabChanged = Observable(*Tab).init(allocator),
.tabPreCurrentItemsUnload = Observable(*Tab).init(allocator),
};
}
pub fn addTab(self: *AppState, tab: Tab) void {
self.tabs.append(tab);
pub fn addTab(self: *AppState, tab: *Tab) !void {
try self.tabs.append(tab);
// tab.preCurrentItemsUnload.attach(.{
// .ctx = @ptrCast(@alignCast(self)),
// .update = preCurrentItemsUnload,
@@ -37,7 +37,7 @@ pub const AppState = struct {
pub fn deinit(self: *AppState) void {
self.tabPreCurrentItemsUnload.deinit();
self.currentTabChanged.deinit();
for (self.tabs.items) |*tab| {
for (self.tabs.items) |tab| {
tab.deinit();
}
self.tabs.deinit();