Skip to content

Commit

Permalink
outward announce
Browse files Browse the repository at this point in the history
  • Loading branch information
rjrodger committed Feb 11, 2018
1 parent f764e72 commit 7868f59
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
16 changes: 14 additions & 2 deletions lib/outward.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2010-2017 Richard Rodger and other contributors, MIT License */
/* Copyright (c) 2010-2018 Richard Rodger and other contributors, MIT License */
'use strict'

var Util = require('util')
Expand All @@ -12,7 +12,8 @@ module.exports = {
act_cache: outward_act_cache,
res_object: outward_res_object,
act_stats: outward_act_stats,
make_error: outward_make_error
make_error: outward_make_error,
announce: outward_announce
}

function outward_make_error(ctxt, data) {
Expand Down Expand Up @@ -113,3 +114,14 @@ function outward_res_object(ctxt, data) {
}
}
}


function outward_announce(ctxt, data) {
if(!ctxt.actdef) return

if (_.isFunction(ctxt.seneca.on_act_out)) {
ctxt.seneca.on_act_out(ctxt.actdef, data.res, data.meta)
}

ctxt.seneca.emit('act-out', data.msg, data.res, data.meta)
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
"scripts": {
"test": "lab -v -P test -L -t 85",
"coveralls": "lab -s -P test -r lcov | coveralls",
"coverage": "lab -v -P test -L -t 90 -r html > docs/coverage.html",
"coverage": "lab -v -P test -L -t 85 -r html > docs/coverage.html",
"annotate": "docco seneca.js lib/*.js -o docs/annotated",
"smoke": "node test/stubs/launch.js",
"prettier": "prettier --write --no-semi --single-quote seneca.js lib/*.js test/*.js"
Expand Down
11 changes: 3 additions & 8 deletions seneca.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2010-2017 Richard Rodger and other contributors, MIT License */
/* Copyright (c) 2010-2018 Richard Rodger and other contributors, MIT License */
'use strict'

// Node API modules.
Expand Down Expand Up @@ -442,6 +442,7 @@ function make_seneca(initial_options) {
.clear(action_queue_clear)
.start()

// TODO: this should be a plugin
// setup status log
if (opts.$.status.interval > 0 && opts.$.status.running) {
private$.stats = private$.stats || {}
Expand Down Expand Up @@ -506,6 +507,7 @@ function make_seneca(initial_options) {
.add(Outward.act_stats)
.add(Outward.act_cache)
.add(Outward.res_object)
.add(Outward.announce)

if (opts.$.test) {
root$.test('string' === typeof opts.$.test ? opts.$.test : 'print')
Expand Down Expand Up @@ -1335,13 +1337,6 @@ intern.handle_reply = function(meta, actctxt, actmsg, err, out, reply_meta) {
result: data.res
})
)

// TODO: this should be in process outward
delegate.emit('act-out', actmsg, data.res, meta)

if (_.isFunction(delegate.on_act_out)) {
delegate.on_act_out(actdef, data.res, meta)
}
}

try {
Expand Down

0 comments on commit 7868f59

Please sign in to comment.