Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

actual results when running tutorial code returns different results, not your expected results #919

Open
mauricefaeh opened this issue May 1, 2023 · 0 comments

Comments

@mauricefaeh
Copy link

mauricefaeh commented May 1, 2023

Hi, I'm working my way trough the quick guide tutorial on your website.

When running the following code example I get different results, not your expected results.

Code from tutorial:
`var seneca = require('seneca')()

seneca.add({role: 'math', cmd: 'sum'}, function (msg, respond) {
var sum = msg.left + msg.right
respond(null, {answer: sum})
})

// both these messages match role: math, cmd: sum

seneca.act({role: 'math', cmd: 'sum', left: 1.5, right: 2.5}, console.log)
seneca.act({role: 'math', cmd: 'sum', left: 1.5, right: 2.5, integer: true}, console.log)

seneca.add({role: 'math', cmd: 'sum', integer: true}, function (msg, respond) {
var sum = Math.floor(msg.left) + Math.floor(msg.right)
respond(null, { answer: sum })
})

// this still matches role: math, cmd: sum
seneca.act({role: 'math', cmd: 'sum', left: 1.5, right: 2.5}, console.log)

// BUT this matches role:math,cmd:sum,integer:true
// because it's more specific - more properties match
seneca.act({role: 'math', cmd: 'sum', left: 1.5, right: 2.5, integer: true}, console.log)`

Expected results:
2016 ... INFO hello ... null { answer: 4 } null { answer: 4 } null { answer: 4 } null { answer: 3 }

Actual results:
{ answer: 4 } { answer: 3 } { answer: 4 } { answer: 3 }

The second act call returns 3 instead of 4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant