now attributes and text are reactive
This commit is contained in:
parent
e93e4b0e38
commit
8a0461c98d
@ -38,13 +38,13 @@ module VueR
|
||||
def trigger(key)
|
||||
puts "Trigger:#{key}"
|
||||
effects = get_subscribers_for(key)
|
||||
effects.each {|effect| effect() }
|
||||
effects.each {|effect| effect.call() }
|
||||
end
|
||||
|
||||
def get_subscribers_for(key)
|
||||
key = key.to_sym
|
||||
unless @subscribers.has_key?(key)
|
||||
@subscribers[key] = []
|
||||
@subscribers[key] = Set.new
|
||||
end
|
||||
@subscribers[key]
|
||||
end
|
||||
|
@ -49,8 +49,16 @@ module VueR
|
||||
end
|
||||
@application.watch_effect(proc)
|
||||
end
|
||||
|
||||
|
||||
def mount_event(element , name)
|
||||
puts "Event: #{name}"
|
||||
native_name = name.gsub("e_" , "")
|
||||
ruby = element[name]
|
||||
puts "Event: #{native_name}:#{ruby}"
|
||||
element.on!(native_name) do
|
||||
got = @application.eval(ruby)
|
||||
puts "Clicked #{got}"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -3,11 +3,13 @@
|
||||
= #@image.attributes
|
||||
|
||||
.flex.justify-center
|
||||
%a.underline{ e_click: "hi" , r_class: 'bg'}
|
||||
%a.underline{ e_click: "bg_change" , r_class: 'bg'}
|
||||
{{ bg }}
|
||||
:opal
|
||||
class Clicker < VueR::Application
|
||||
|
||||
def bg_change
|
||||
self.bg = "bg-cyan-50"
|
||||
end
|
||||
end
|
||||
|
||||
kanta = Clicker.new(bg: 'bg-cyan-200')
|
||||
|
Loading…
Reference in New Issue
Block a user