mirror of
https://github.com/centau/vide.git
synced 2026-08-20 14:41:37 +00:00
Improve error messages for derived sources
There seemed to be confusion over reactive-scoping (likely due to incomplete docs), so I've added more explicit error messages when deriving in non-reactive scopes to warn the user to use `root()` or `mount()`.
This commit is contained in:
parent
d13f66a1e1
commit
c4a0180a2f
9 changed files with 31 additions and 42 deletions
|
|
@ -27,7 +27,7 @@ type Node<T> = graph.Node<T>
|
|||
type StartNode<T> = graph.StartNode<T>
|
||||
local create_node = graph.create_node
|
||||
local create_start_node = graph.create_start_node
|
||||
local get_scope = graph.get_scope
|
||||
local get_owning_scope = graph.get_owning_scope
|
||||
local evaluate_node = graph.evaluate_node
|
||||
local update = graph.update
|
||||
local set_owner = graph.set_owner
|
||||
|
|
@ -150,10 +150,7 @@ local springs: { [SpringData<any>]: StartNode<any> } = {}
|
|||
setmetatable(springs, { __mode = "v" })
|
||||
|
||||
local function spring<T>(source: () -> T, period: number?, damping_ratio: number?): () -> T
|
||||
local owner = get_scope()
|
||||
if not owner then
|
||||
throw("cannot derive in non-reactive scope")
|
||||
end; assert(owner)
|
||||
local owner = get_owning_scope()
|
||||
|
||||
-- https://en.wikipedia.org/wiki/Damping
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue