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

fat arrow support in seneca 1.0, via msg.meta$.seneca #288

Closed
rjrodger opened this issue Jan 4, 2016 · 4 comments
Closed

fat arrow support in seneca 1.0, via msg.meta$.seneca #288

rjrodger opened this issue Jan 4, 2016 · 4 comments
Assignees
Milestone

Comments

@rjrodger
Copy link
Collaborator

rjrodger commented Jan 4, 2016

The problem is that the this reference is not correct when using => (it's not the current seneca context).

Instead, provide it via the meta$ message property:

seneca.add( 'foo:1', (msg, done) => { msg.meta$.seneca.prior( ... ) })

@geek
Copy link
Member

geek commented Jan 5, 2016

After further thought, I am going to add the instance to the callback function. The reason for this is that the meta$ object should be serializable, plus its a reserved property.

const Seneca = require('seneca');

const seneca = Seneca();
seneca.add('foo: 1', (msg, reply) => { 
  reply.seneca.act('foo: 2', function (err, result) {
    reply(err, result + 2);
  });
}); 

When trying to add seneca to meta$ there was an error trying to serialize the instance in the gate executor.

@geek geek added this to the 0.9.4 milestone Jan 5, 2016
@mcollina
Copy link
Contributor

mcollina commented Jan 5, 2016

Following chairo:

const Seneca = require('seneca');

const seneca = Seneca();
seneca.add('foo: 1', (msg, reply) => { 
  reply.act('foo: 2', function (err, result) {
    reply(err, result + 2);
  });
});

seneca.add('foo: 2', (msg, reply) => { 
  reply.act('foo: 3'); // meaningless, but helpful
}); 

@rjrodger
Copy link
Collaborator Author

rjrodger commented Jan 5, 2016

Ah good catch! Agreed

@mcdonnelldean
Copy link
Contributor

Damn, I JUST came here to raise this point! As you were...

@geek geek closed this as completed in #290 Jan 6, 2016
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

4 participants