mirror of
https://github.com/centau/vide.git
synced 2026-08-20 14:41:37 +00:00
Refactor
This commit is contained in:
parent
67e87110c7
commit
f2de9b0e63
25 changed files with 315 additions and 364 deletions
|
|
@ -4,14 +4,14 @@ local throw = require(script.Parent.throw)
|
|||
local graph = require(script.Parent.graph)
|
||||
type Node<T> = graph.Node<T>
|
||||
local create_node = graph.create_node
|
||||
local open_scope = graph.open_scope
|
||||
local close_scope = graph.close_scope
|
||||
local push_scope = graph.push_scope
|
||||
local pop_scope = graph.pop_scope
|
||||
local destroy = graph.destroy
|
||||
|
||||
local refs = {}
|
||||
|
||||
local function root<T...>(fn: (destroy: () -> ()) -> T...): T...
|
||||
local node = create_node(false, false)
|
||||
local node = create_node(false, false, false)
|
||||
|
||||
refs[node] = true -- prevent gc of root node
|
||||
|
||||
|
|
@ -21,11 +21,11 @@ local function root<T...>(fn: (destroy: () -> ()) -> T...): T...
|
|||
destroy(node)
|
||||
end
|
||||
|
||||
open_scope(node)
|
||||
push_scope(node)
|
||||
|
||||
local result = { pcall(fn, destroy) }
|
||||
|
||||
close_scope()
|
||||
pop_scope()
|
||||
|
||||
if not result[1] then
|
||||
refs[node] = nil
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue