'NodeJs pass parameter to callback function in 3rd party library
There is some public library with code like this:
function SomeFunc(param1, param2, param3, onEnd) {
//does something
log.ok("Finished processing: " + param1);
onEnd();
};
Later, in my code, when I use this library I call a method with parameters
SomeFunc(value1, value2, value3, onEnd);
OnEnd is called when function finished tasks.
This is an implementation of OnEnd in my code that works fine
var onEnd = function() {
console.log("Hello World");
};
As you can see, it works without parameters. What I want to achieve, is to pass a parameter to onEnd("Something_important") but I get an error:
TypeError: onEnd is not a function
I've tried following:
var onEnd =function(param) { };
onEnd("Something_important");
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
