From 179a7f6ffa08b7df7c228f0912988e29324456e9 Mon Sep 17 00:00:00 2001 From: Nikhil Marathe Date: Tue, 19 Oct 2010 09:06:26 +0530 Subject: [PATCH] Added documentation of EventEmitter.once --- doc/api.markdown | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/doc/api.markdown b/doc/api.markdown index 26842224e2..47ce73059a 100644 --- a/doc/api.markdown +++ b/doc/api.markdown @@ -244,6 +244,15 @@ Adds a listener to the end of the listeners array for the specified event. console.log('someone connected!'); }); +### emitter.once(event, listener) + +Adds a **one time** listener for the event. The listener is +invoked only the first time the event is fired, after which +it is removed. + + server.once('connection', function (stream) { + console.log('Ah, we have our first user!'); + }); ### emitter.removeListener(event, listener)