Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save yoshifumi0521/4110318 to your computer and use it in GitHub Desktop.
Save yoshifumi0521/4110318 to your computer and use it in GitHub Desktop.
イベントを発生させるか?を書いてみる。
//イベントを発生させるオブジェクトを作成
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