Created
April 3, 2010 13:47
-
-
Save Slashed/354490 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var sys = require('sys'); | |
var hotcode = require('./hotcode'); | |
var exampleLib = hotcode.load('./example_lib'); | |
sys.puts(exampleLib.Name); // Output: "John" | |
// ...e.g. some changes were made to file. | |
exampleLib = hotcode.load('./example_lib'); | |
sys.puts(exampleLib.Name); // Output: "Victoria" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var sys = require('sys'); | |
var hotcode = require('./hotcode'); | |
// Auto hot code loading. Second argument is a callback with reference to exported functions. | |
var exampleLib = hotcode.load('./example_lib', function(obj) { | |
sys.puts('Reloading "example_lib"..'); | |
exampleLib = obj; | |
}); | |
var Msg = 'Name(or type "unwatch" to stop Auto Code Loading): '; | |
process.stdio.open(); | |
sys.print(Msg); | |
process.stdio.addListener('data', function(data) { | |
data = data.trim(); | |
if(data == 'unwatch') { | |
hotcode.unwatch('./example_lib'); | |
} else { exampleLib.sayHello(data); } | |
sys.print(Msg); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment