Skip to content

Commit

Permalink
Document public hooks in AS::Reloader [ci skip]
Browse files Browse the repository at this point in the history
  • Loading branch information
kirs committed Aug 14, 2017
1 parent 904f1a8 commit a41c55c
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions activesupport/lib/active_support/reloader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,17 @@ class Reloader < ExecutionWrapper

define_callbacks :class_unload

# Registers a callback that will run once at application startup and every time the code is reloaded.

This comment has been minimized.

Copy link
@Sporky023

Sporky023 Sep 17, 2018

What is meant by "every time the code is reloaded" here? Does this refer to page refresh? Does it refer to a reload process triggered by a reload! call in a console?

My context for asking is that I'm trying to understand this line of the pull request at: https://github.com/teohm/require_reloader/pull/7/files#diff-10cbf865555f200a581ee4b1b09ed2e4R84

Thank you.

This comment has been minimized.

Copy link
@Sporky023

Sporky023 Sep 17, 2018

I answered my own question by experimentation: this runs during server startup and does not run on each request. I can't characterize more precisely exactly when it does run, but it doesn't run during request cycle which was my focus.

This comment has been minimized.

Copy link
@kirs

kirs Sep 19, 2018

Author Member

@Sporky023 it depends on how your app configures code reload (app.config.file_watcher), but it usually happens when the actual code is changed. That's why you won't see the callback being called during request cycle unless you change some class between requests.

Does it refer to a reload process triggered by a reload! call in a console?

IIRC it does, since reload! triggers the code reload mechanism.

def self.to_prepare(*args, &block)
set_callback(:prepare, *args, &block)
end

# Registers a callback that will run immediately before the classes are unloaded.
def self.before_class_unload(*args, &block)
set_callback(:class_unload, *args, &block)
end

# Registers a callback that will run immediately after the classes are unloaded.
def self.after_class_unload(*args, &block)
set_callback(:class_unload, :after, *args, &block)
end
Expand Down

0 comments on commit a41c55c

Please sign in to comment.