Tom Hallett

Joined

20 Experience
0 Lessons Completed
0 Questions Solved

Activity

Posted in Introduction to Stimulus Reflex Discussion

Chris,

Broadcasting a stimilus reflex page to other users seems problematic for a few reasons - dirty state (as you mentioned) and having a page looking exactly the same for 2 different users is probably the exception to the rule (in the same way that full page caching is the exception to the rule).

I'm wondering if you could break it down into a few smaller problems:
1) user A makes SR update
2) persist that update into a temporary storage (redis)
3) let SR update user A's entire page (as usual)
4) broadcast a standard "page_updated" event to user B
5) user B's page should do an SR update (based on receiving "page_updated" event)
6) in your reflex action, merge user B's data with user A's data in redis
7) SR will update user B's entire page

There are a few questions/risks with this approach:
1) should all of user A's SR updates be broadcast (even one's w/ errors) or just the ones where user A actually hits save and are actually persisted to the production DB?
2) how do you do the "merge" step in step 6??? will a simple approach work? is it possible to record each SR update (similar to a redux action) so they can be "replayed"? CRDT (blah!)?
3) if there are many user B's, step 5 could make a herd of network requests

Now that I've typed all of that, this approach seems like very very difficult (and this type of conflict resolution is not even something react/redux can solve out of the box).

A simpler approach would be: SR for user A and cable ready for user B. I can imagine 2 flavors of this:

A) If a new piece of data was added (to a list or something) use cable ready to add that entry to user B's list.
B) If data was edited in some dirty way, use cable ready to add a "This page has been updated. Click here to refresh" link to user B's page and let them decide what todo.

Really curious where you end up here.

Thanks,
Tom

Posted in Introduction to Stimulus Reflex Discussion

I'm interested if this will become the defacto/recommended way to build modern rails apps (the "view source" way, https://m.signalvnoise.com/paying-tribute-to-the-web-with-view-source/)....

Does anyone know if stimilus_reflex has gotten any love from the rails core team (or basecamp)?

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.