Sha256: 7340e2c1ec02e47cb7de5fe73f298220804210df3843fc058332a7cca3afefcf

Contents?: true

Size: 968 Bytes

Versions: 2

Compression:

Stored size: 968 Bytes

Contents

# app/views/components/app.rb
class Words < React::Component::Base

  param :words

  render(UL) do
    params.words.each { |word| LI { word.text } }
  end

  hypertrace instrument: :all

end


class App < React::Component::Base

  define_state :waiting_for_word

  def add_new_word
    # for fun we will use setgetgo.com to get random words!
    state.waiting_for_word! true
    HTTP.get("http://randomword.setgetgo.com/get.php", dataType: :jsonp) do |response|
      Word.new(text: response.json[:Word]).save { state.waiting_for_word! false }
    end
  end

  render(DIV) do
    SPAN { "Count of Words: #{Word.count}" }
    BUTTON { "add another" }.on(:click) { add_new_word } unless state.waiting_for_word
    #Words(words: Word.all)
    UL do
      Word.each { |word| LI { word.text } }
    end
  end

  hypertrace instrument: :render
end

#ReactiveRecord::Collection.hypertrace instrument: :instance_variable_set
#React::State.hypertrace :class, instrument: :all

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
hyper-mesh-0.5.0 examples/simple-poller/app/views/components/app.rb
hyper-mesh-0.4.0 examples/simple-poller/app/views/components/app.rb