now attributes and text are reactive

This commit is contained in:
Torsten 2023-02-07 18:56:28 +02:00
parent e93e4b0e38
commit 8a0461c98d
3 changed files with 15 additions and 5 deletions

View File

@ -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

View File

@ -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

View File

@ -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')