Sha256: 279e7842dc91e5572a3012f0e612d677a808615a973e59eb4db8535d6ba8e901
Contents?: true
Size: 926 Bytes
Versions: 4
Compression:
Stored size: 926 Bytes
Contents
require 'ovto' class MyApp < Ovto::App class State < Ovto::State item :celsius, default: 0 def fahrenheit (celsius * 9 / 5.0) + 32 end end class Actions < Ovto::Actions def set_celsius(state:, value:) return {celsius: value} end def set_fahrenheit(state:, value:) new_celsius = (value - 32) * 5 / 9.0 return {celsius: new_celsius} end end class View < Ovto::Component def render(state:) o 'div' do o 'span', 'Celcius:' o 'input', { type: 'text', onchange: ->(e){ actions.set_celsius(value: e.target.value.to_i) }, value: state.celsius } o 'span', 'Fahrenheit:' o 'input', { type: 'text', onchange: ->(e){ actions.set_fahrenheit(value: e.target.value.to_i) }, value: state.fahrenheit } end end end end MyApp.run(id: 'ovto-view')
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
ovto-0.2.3 | example/static/app.rb |
ovto-0.2.2 | example/static/app.rb |
ovto-0.2.1 | example/static/app.rb |
ovto-0.2.0 | example/static/app.rb |