Events and Callbacks
class ClickDemo2 < HyperComponent
render do
BUTTON { "click" }.on(:click) { |evt| puts "I was clicked"}
end
endFiring Events from Components
class Clicker < HyperComponent
param title: "click"
fires :clicked
before_mount { @clicks = 0 }
render do
BUTTON { title }.on(:click) { clicked!(@clicks += 1) }
end
end
class ClickDemo3 < HyperComponent
render(DIV) do
DIV { "I have been clicked #{pluralize(@clicks, 'times')}" } if @clicks
Clicker().on(:clicked) { |clicks| mutate @clicks = clicks }
end
endRelationship between Events and Params
Callbacks and Proc Params
Naming Conventions
The Event Object
Event ObjectOther Sources of Events
Last updated
Was this helpful?