Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added example for multiple actions

  • Loading branch information...
commit 70c0a1995073cf47a8f50b87180e0ba657f7ce1a 1 parent 8b9fe86
TJ Holowaychuk authored
6 examples/refresh_browsers.rb
View
@@ -3,8 +3,10 @@
# Execute this file to start the listener, then alter style.css a few times
+actions = []
html = File.expand_path(File.dirname(__FILE__) + '/demo.html')
style = File.dirname(__FILE__) + '/style.css'
-action = Bind::Actions::RefreshBrowsers.new html, 'Safari', 'Firefox'
-listener = Bind::Listener.new :event => :change, :paths => [style], :interval => 1, :actions => [action], :timeout => 60, :debug => $stdout
+actions << lambda { |file| puts "modified #{file.path}" }
+actions << Bind::Actions::RefreshBrowsers.new(html, 'Safari')
+listener = Bind::Listener.new :event => :change, :paths => [style], :interval => 1, :actions => actions, :timeout => 60
listener.run!
3  examples/style.css
View
@@ -1,2 +1,3 @@
h1 {
- color: red; }
+ color: blue;
+}
1  lib/bind/listener.rb
View
@@ -79,6 +79,7 @@ def run!
# Invoke all current actions with a +file+.
def call_actions_with file
+ p actions
actions.each { |action| action.call file }
end
Please sign in to comment.
Something went wrong with that request. Please try again.