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
|
|
@ -1,17 +1,13 @@
|
|||
if not game then script = require "test/relative-string" end
|
||||
|
||||
local throw = require(script.Parent.throw)
|
||||
local graph = require(script.Parent.graph)
|
||||
local create_node = graph.create_node
|
||||
local get_scope = graph.get_scope
|
||||
local get_owning_scope = graph.get_owning_scope
|
||||
local evaluate_node = graph.evaluate_node
|
||||
local set_owner = graph.set_owner
|
||||
|
||||
local function effect<T>(callback: (T) -> T, initial_value: T)
|
||||
local owner = get_scope()
|
||||
if not owner then
|
||||
throw("cannot create effect in non-reactive scope")
|
||||
end; assert(owner)
|
||||
local owner = get_owning_scope()
|
||||
|
||||
local node = create_node(initial_value, callback)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue