Created
November 19, 2012 12:04
-
-
Save yoshifumi0521/4110318 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
//イベントを発生させるオブジェクトを作成 | |
var events = require("events"); | |
var emitter = new events.EventEmitter(); | |
//発生させる関数を定義 | |
var sampleListener = function(arg1){ | |
console.log("arg1"); | |
} | |
//イベント("occurrence")を定義して、関数をむすびつける。 | |
emitter.on("occurrence",sampleListener); | |
//イベントを発生させる | |
emitter.emit("occurrence"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment