Toggle navigation
Toggle navigation
This project
Loading...
Sign in
I_Jemin
/
Node-Study
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
I_Jemin
2018-03-22 00:11:43 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
7311384700093fb4148d2a3f4225e44ba1b792f2
73113847
1 parent
c06cc8be
Event is bounded to single Event Emitter, event call won't be global
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
8 deletions
app.js
logger.js
app.js
View file @
7311384
...
...
@@ -6,9 +6,10 @@ emitter.on('messageLogged', (arg) => {
console
.
log
(
'Listener called'
,
arg
);
});
emitter
.
on
(
'logging'
,
(
e
)
=>
{
console
.
log
(
'Loggin Event'
,
e
);});
const
log
=
require
(
'./logger'
);
log
(
'message'
);
emitter
.
emit
(
'messageLogged'
,
{
id
:
1
,
url
:
'http://'
});
// Raise: logging (data: message)
emitter
.
emit
(
'logging'
,
'Jemin'
);
...
...
logger.js
View file @
7311384
console
.
log
(
__filename
);
console
.
log
(
__dirname
);
var
url
=
'http://mylogger.io/log'
;
const
EventEmitter
=
require
(
'events'
);
const
emitter
=
new
EventEmitter
();
var
url
=
'http:mylogger.io/log'
;
function
log
(
message
)
{
// Send an HTTP request
console
.
log
(
message
);
emitter
.
emit
(
'messageLogged'
,
{
id
:
1
,
url
:
'http://'
});
}
module
.
exports
=
log
;
...
...
Please
register
or
login
to post a comment