Skip to content

Commit

Permalink
add happen method for get last arg in emit
Browse files Browse the repository at this point in the history
  • Loading branch information
behnammodi committed Nov 22, 2018
1 parent d3edf6d commit 9cd00a8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions index.js
Expand Up @@ -2,6 +2,7 @@

exports.__esModule = true;
var subscribes = {};
var happens = {};

exports.on = function on(name, func) {
subscribes[name] = subscribes[name] || [];
Expand All @@ -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];
}
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "jetemit",
"version": "1.0.3",
"version": "1.1.0",
"description": "",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit 9cd00a8

Please sign in to comment.