Skip to content

Commit 5c2fa45

Browse files
committed
refactor(state): rename notify to emit
1 parent 153c1a2 commit 5c2fa45

3 files changed

Lines changed: 5 additions & 155 deletions

File tree

lua/opencode/state/init.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ local M = {
9393
context = context,
9494
subscribe = store.subscribe,
9595
unsubscribe = store.unsubscribe,
96-
notify = store.notify,
96+
emit = store.emit,
9797
append = store.append,
9898
remove = store.remove,
9999
}

lua/opencode/state/store.lua

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ function M.set(key, value, opts)
8282

8383
_state[key] = value
8484
if not vim.deep_equal(old, value) then
85-
M.notify(key, value, old)
85+
M.emit(key, value, old)
8686
end
8787

8888
return value
@@ -148,7 +148,7 @@ function M.unsubscribe(key, cb)
148148
end
149149
end
150150

151-
function M.notify(key, new_val, old_val)
151+
function M.emit(key, new_val, old_val)
152152
vim.schedule(function()
153153
if _listeners[key] then
154154
for _, cb in ipairs(_listeners[key]) do
@@ -182,7 +182,7 @@ function M.append(key, value)
182182

183183
local old = vim.deepcopy(_state[key] --[[@as table]])
184184
table.insert(_state[key] --[[@as table]], value)
185-
M.notify(key, _state[key], old)
185+
M.emit(key, _state[key], old)
186186
end
187187

188188
---@param key string
@@ -197,7 +197,7 @@ function M.remove(key, idx)
197197

198198
local old = vim.deepcopy(_state[key] --[[@as table]])
199199
table.remove(_state[key] --[[@as table]], idx)
200-
M.notify(key, _state[key], old)
200+
M.emit(key, _state[key], old)
201201
end
202202

203203
return M

state_refactor.md

Lines changed: 0 additions & 150 deletions
This file was deleted.

0 commit comments

Comments
 (0)