-
Notifications
You must be signed in to change notification settings - Fork 754
Fix for Issue #212 components.js generated by assets:precompile #213
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,7 +65,7 @@ class Railtie < ::Rails::Railtie | |
config.after_initialize do |app| | ||
# Server Rendering | ||
# Concat component_filenames together for server rendering | ||
app.config.react.components_js = lambda { | ||
app.config.react.components_js ||= lambda { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A naive There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I din't get you, how over here?
No. As a rule of thumb, its better to avoid There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm still confused as to how a plain There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @RearAdmiral
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @RearAdmiral I am not sure, how else I could explain this 😄 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't know much about threadsafety and Rails, but I thought I'd see if other gems do the same or not. I found a couple examples: https://github.com/rails/sass-rails/blob/master/lib/sass/rails/railtie.rb#L69-L74 https://github.com/rails/rails/blob/master/activejob/lib/active_job/railtie.rb#L14-L15 (I didn't find any Is there a reason those are different than our case? If it works for them, can we expect it to work for us? If not, does anyone threadsafe suggestion? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @vipulnsward It would be much easier with a whiteboard :-) but I would appreciate if you'd explain more because I wasn't aware of this problem and would like to learn more.
What are the possible values then? I assumed it would either remain unchanged or be set to 10. I still don't think either implementation is threadsafe. For example,if our react-rails init thread has just checked if So are you specifically referring to this code being run simultaneously by multiple threads and leading to unexpected outcomes? By my reading, the unexpected outcome would be the creation of two lambdas which is wasteful but wouldn't break any functionality. Can you explain a case where it would break? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For posterity, there is no difference between an |
||
app.config.react.component_filenames.map do |filename| | ||
app.assets[filename].to_s | ||
end.join(";") | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extra space