Skip to content
Snippets Groups Projects
Commit 3e681153 authored by Jacob Wikmark's avatar Jacob Wikmark
Browse files

obs => observe

parent 91b97ae9
No related branches found
No related tags found
No related merge requests found
......@@ -17,7 +17,7 @@ end
function map_block(block, symbols)
lambda = Expr(:(->), Expr(:tuple, symbols...),
block)
:(map($lambda, $(map(s->:(obs($s)), symbols)...)))
:(map($lambda, $(map(s->:(observe($s)), symbols)...)))
end
function symbols(bindings)
......
......@@ -80,7 +80,7 @@ Used to set the widgets, the dom or the data array of the GUI. This replaces any
"""
function set!(gui::GUI, widgets::Widget_Container)
gui.widgets = widgets
gui.values = [obs(widget).val for widget in gui.widgets.widgets]
gui.values = [observe(widget).val for widget in gui.widgets.widgets]
end
function set!(gui::GUI, dom::WebIO.Node)
......@@ -109,11 +109,11 @@ function Base.push!(gui::GUI, values::Tuple, indices::Tuple)
end
function Base.getindex(gui::GUI, s::Symbol)
obs(gui.widgets[s])[]
observe(gui.widgets[s])[]
end
function Base.setindex!(gui::GUI, newval, s::Symbol)
obs(gui.widgets[s])[] = newval
observe(gui.widgets[s])[] = newval
end
"""
......@@ -126,7 +126,7 @@ function add!(gui::GUI, widgets::Widget_Container)
end
gui.widgets.widgets = vcat(gui.widgets.widgets, widgets.widgets)
gui.widgets.vals = merge(gui.widgets.vals, newdict)
gui.values = vcat(gui.values, [obs(w)[] for w in widgets.widgets])
gui.values = vcat(gui.values, [observe(w)[] for w in widgets.widgets])
end
......@@ -196,14 +196,14 @@ function update(gui::GUI, s::Symbol, watchsymbol=:0)
# if the value of the widget associated with watchsymbol has changed
w = gui.widgets[s]
if watchsymbol==:0||has_changed(gui, watchsymbol)
#obs(w).listeners[2](obs(w)[])
obs(w)[] = obs(w)[]
#observe(w).listeners[2](observe(w)[])
observe(w)[] = observe(w)[]
end
end
function update(gui::GUI, a::Array, watchsymbol=:0)
W = [gui.widgets[s] for s in a]
if watchsymbol==:0||has_changed(gui, watchsymbol)
[obs(w).listeners[2](obs(w)[]) for w in W]
[observe(w).listeners[2](observe(w)[]) for w in W]
end
end
......
......@@ -4,7 +4,7 @@ Links the values of two observables by adding a listener. Optional arguments f a
Example:
link(o1, o2, (x) -> 2*x, (x) -> x/2)
will ensure obs(o2)[] is always 2*obs(o1)[] and vice versa.
will ensure observe(o2)[] is always 2*observe(o1)[] and vice versa.
"""
function link!(o1::Observable, o2::Observable, f = (x)->(x), g = (x)->(x), master=false)
......
......@@ -59,7 +59,7 @@ end
add!(gui, wid2)
gui[:dummy] = 23
@test typeof(gui()) <: WebIO.Node
@test obs(dummy)[] == 23
@test observe(dummy)[] == 23
@test gui.widgets[:dummy] == dummy
end
......@@ -86,6 +86,6 @@ end
WebIO.render(dummy)
end
@test typeof(ui) <: WebIO.Node{WebIO.DOM}
obs(dummy)[] = 80
@test obs(dummy)[] == 80
observe(dummy)[] = 80
@test observe(dummy)[] == 80
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment