Skip to content

Commit 526cf25

Browse files
committed
feat: add global cache to App
1 parent eee8d92 commit 526cf25

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

lua/grapple/app.lua

+10-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---@class grapple.app
22
---@field settings grapple.settings
3+
---@field cache grapple.cache
34
---@field scope_manager grapple.scope_manager
45
---@field tag_manager grapple.tag_manager
56
local App = {}
@@ -29,21 +30,26 @@ function App:new()
2930
local State = require("grapple.state")
3031
local TagManager = require("grapple.tag_manager")
3132

33+
local settings = Settings:new()
34+
3235
local app = setmetatable({
33-
settings = nil,
36+
settings = settings,
37+
cache = Cache:new(),
3438
scope_manager = nil,
3539
tag_manager = nil,
3640
}, self)
3741

38-
local settings = Settings:new()
39-
42+
-- TODO: I think the "scope" cache and "glboal" cache should be separate.
43+
-- Think about this more and decided on the best approach. Note: right now
44+
-- the scope manager only really needs the "app" to get the tag_manager for
45+
-- a single method. A bit of refactoring could probably remove this
46+
-- dependency
4047
local cache = Cache:new()
4148
local scope_manager = ScopeManager:new(app, cache)
4249

4350
local state = State:new(settings.save_path)
4451
local tag_manager = TagManager:new(app, state)
4552

46-
app.settings = settings
4753
app.scope_manager = scope_manager
4854
app.tag_manager = tag_manager
4955

0 commit comments

Comments
 (0)