Reverse Text

Prints whatever you type in reverse order

Explanation

No custom JavaScript was written for this demo. It uses the data-reflex attributes to produce the behavior.

Code (8 LOC)

ERB (3 LOC)
app/views/reverse_texts/_demo.html.erb (3 LOC)
<input id="data-entry" type="text" data-reflex="debounced:keyup->ReverseTextReflex#perform"
placeholder="Type something..." class="form-control form-control-lg d-inline-block col-4">
<span class="ml-3"><%= @value %></span>
Ruby (5 LOC)
app/reflexes/reverse_text_reflex.rb (5 LOC)
class ReverseTextReflex < ApplicationReflex
def perform
@value = element[:value].reverse
end
end