-
Notifications
You must be signed in to change notification settings - Fork 341
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
Using prototype functions in napa #238
Comments
I don't get what's the question... could you share an example to help me understand? I've tried the const napa = require('napajs');
let z1 = napa.zone.create('z1', { workers: 1 });
z1.broadcastSync(()=>{
let moment = require('moment');
console.log(moment().format("MMM Do YY"));
}); This does not work: z1.broadcastSync(()=>{
let moment = require('moment');
});
z1.execute(()=>{
console.log(moment().format("MMM Do YY")); //ReferenceError: moment is not defined
}); By using z1.broadcastSync(()=>{
global.moment = require('moment');
});
z1.execute(()=>{
console.log(global.moment().format("MMM Do YY"));
}); |
Thank you fs-eire! I have a class |
In my previous attempt I always put definitions of customized class into a separated file. Say I have a file greedy.js with the definition of optimize() inside so I broadcast a call to |
I'm trying to use napajs with prototype functions. How can I bind 'this' inside the broadcast api?
Moreover, I'm trying to require momentjs and toolbox inside broadcast, but it's not working.
The text was updated successfully, but these errors were encountered: