From bbc0df362a727d1f852efa0f5fe5c1dfcde0ee86 Mon Sep 17 00:00:00 2001 From: Deepak Swami Date: Mon, 19 Dec 2016 19:03:00 +0530 Subject: [PATCH] Added event name in listener to get it in result function call(); It will be useful if we assign same listener to multiple events. Recently I used this library in my android project with node.js and raspberry pi + arduino I used this emitter callback function to get two events temprature and light state data, Using previous functions i have to assign two seperate Listner functions for both of them but if we use event name which is also available in emitter class i can solve my problem. Hope you understand this what i want to say. thanks in advance and sorry for my bad english. --- src/android/com/github/nkzawa/emitter/Emitter.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/android/com/github/nkzawa/emitter/Emitter.java b/src/android/com/github/nkzawa/emitter/Emitter.java index a681dd4..66d6d3b 100644 --- a/src/android/com/github/nkzawa/emitter/Emitter.java +++ b/src/android/com/github/nkzawa/emitter/Emitter.java @@ -114,7 +114,7 @@ public Emitter emit(String event, Object... args) { ConcurrentLinkedQueue callbacks = this.callbacks.get(event); if (callbacks != null) { for (Listener fn : callbacks) { - fn.call(args); + fn.call(event, args); } } return this; @@ -145,7 +145,7 @@ public boolean hasListeners(String event) { public static interface Listener { - public void call(Object... args); + public void call(String event, Object... args); } private class OnceListener implements Listener { @@ -161,7 +161,7 @@ public OnceListener(String event, Listener fn) { @Override public void call(Object... args) { Emitter.this.off(this.event, this); - this.fn.call(args); + this.fn.call(this.event, args); } } }