Skip to content

Instantly share code, notes, and snippets.

@jgaskins
Created October 4, 2015 07:03
Show Gist options
  • Save jgaskins/f09c3aa980367ede72e4 to your computer and use it in GitHub Desktop.
Save jgaskins/f09c3aa980367ede72e4 to your computer and use it in GitHub Desktop.
Brainstorm for Clearwater routing callbacks
class Router
def navigate_to path
current_targets = targets_for_path(current_path)
new_targets = targets_for_path(path)
(current_targets - new_targets).each do |from_target|
if from_target.respond_to?(:will_transition_from)
from_target.will_transition_from
end
end
(new_targets - current_targets).each do |to_target|
if to_target.respond_to?(:will_transition_to)
to_target.will_transition_to
end
end
# do whatever it does currently
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment