From 9cd00a8b4540669b59b02e8057c2e30597f8517a Mon Sep 17 00:00:00 2001 From: Behnam Mohammadi Date: Thu, 22 Nov 2018 14:39:55 +0330 Subject: [PATCH] add happen method for get last arg in emit --- index.js | 5 +++++ package.json | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 62861c4..2122ea4 100644 --- a/index.js +++ b/index.js @@ -2,6 +2,7 @@ exports.__esModule = true; var subscribes = {}; +var happens = {}; exports.on = function on(name, func) { subscribes[name] = subscribes[name] || []; @@ -13,9 +14,13 @@ exports.on = function on(name, func) { exports.emit = function emit(name, arg) { if (subscribes[name]) { + happens[name] = arg; subscribes[name].forEach(function (func) { func && func(arg); }); } }; +exports.happen = function happen(name) { + return happens[name]; +} \ No newline at end of file diff --git a/package.json b/package.json index 74afd8a..0de9131 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "jetemit", - "version": "1.0.3", + "version": "1.1.0", "description": "", "main": "index.js", "scripts": {