Alex Park

Joined

30 Experience
0 Lessons Completed
0 Questions Solved

Activity

Posted in Introduction to Stimulus Reflex Discussion

dev experience looks amazing! looks like the library already throttles/debounces event-generating monsters like mouse move and scrolling, which was my primary concern as soon as I saw you listen to the change event. It also looks like it does DOM diffing and permanent elements and partial DOM updates too!

The only concern i have is if the server can handle the increase in request frequency. server-side performance will be a topic sooner when using stimulus reflex. The form validation example you used seemed to take longer than i expected to appear in the page.

Posted in Dynamic Nested Forms with Stimulus JS Discussion

When writing rails system tests, it might not be intuitive how to fill in multiple inputs that have the same label, but here is how I did it:

def test_create_multiple_tasks_from_project
  visit new_project_path
  click_on 'Add Task' # now there are 2 Task inputs with the same Task Label
  all("input[id^='project_tasks_attributes'][id$='_description']").each.with_index do |task, index|
    task.fill_in with: "Task number #{index}!"
  end
  click 'Save Project'
  assert_text "Task number 0!"
  assert_text "Task number 1!"

Posted in Dynamic Nested Forms with Stimulus JS Discussion

Because the task_fields partial is a continuation of the form builder, it doesn't lend itself to the optimized partial render for collections. In your server logs, you'll see a lot of:

rendered partial 'projects/task_fields' (Duration 0.1 to 0.5 ms)
for each task in your project.

I'm not sure how to optimize this b/c of the form builder pattern is making this slightly different than the normal use case for collection partial renders.

logo Created with Sketch.

Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

© 2020 GoRails, LLC. All rights reserved.