- Notifications
You must be signed in to change notification settings - Fork 750
Reload all dependent JS when files change #98
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 1 commit
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 |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| require 'react/rails/railtie' | ||
| require 'react/rails/engine' | ||
| require 'react/rails/reloader' | ||
| require 'react/rails/view_helper' |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| require 'rails' | ||
| | ||
| module React | ||
| module Rails | ||
| | ||
| class Reloader | ||
| def self.on_change(watch_files, &block) | ||
| unless block_given? | ||
| warn "Reloader.on_change requires a callback block" | ||
| end | ||
| Contributor 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.
Author 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. Fair point. I have removed the extra check. | ||
| | ||
| @@file_checker = ActiveSupport::FileUpdateChecker.new(watch_files, &block) | ||
| end | ||
| | ||
| def initialize(app) | ||
| @app = app | ||
| end | ||
| | ||
| def call(env) | ||
| execute_if_updated! | ||
| @app.call(env) | ||
| end | ||
| | ||
| private | ||
| | ||
| def execute_if_updated! | ||
| @@file_checker.execute_if_updated if @@file_checker | ||
| Contributor 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. Here too, extra if condition isn't required, we are defining this ourselves. Author 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. This check is actually required, because | ||
| end | ||
| end | ||
| | ||
| end | ||
| end | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| //= require_self | ||
| //= require todo-helper | ||
| //= require_tree ./components |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| window.todoHeader = function() { | ||
| return "<li>Injected Header</li>"; | ||
| }; |
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.
How about
component_source_filesorcomponent_sources, since we are catching multiple files here?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.
We are catching multiple files, but it ends up as a single large source block. So I have renamed to
combined_components_sourceto better document its purpose.