What are different ways that we can define callback mechanism from javascript to java? A java method calling callback in javascript - node-java

Can we define a context in node addon and trigger call from Java to JavaScript via node addon? Has anyone tried this?
I don't see any support for callback in JNI header. But if someone has achieved this by mixing call from javascript to java and then call from java to javascript, that would be great

Related

Use Typescript in some part of the app only

I have a node js application.
All the codes are now in javascript.
But in some part of my app I want to use Typescript Interface or enum options.
How can I use Typescript just for those part of the app?
I don't want to refactor all the project to using Typescript.
You can try Flow https://flow.org
Flow in opposition to TypeScript isn't a superset or language. It's a static type checker for JavaScript. Because it's not a language, it can be smoothly integrated with JavaScript with a single comment annotation.
You can add a single .ts file, and use plain javascript for the rest of them.
https://www.typescriptlang.org/
TypeScript is a typed superset of JavaScript that compiles to plain
JavaScript.
[...] Use existing JavaScript code, incorporate popular JavaScript
libraries, and call TypeScript code from JavaScript.
TypeScript compiles to clean, simple JavaScript code which runs on any
browser, in Node.js, or in any JavaScript engine that supports
ECMAScript 3 (or newer).

Checking what methods were invoked during execution typescript on node js server (debugging nodejs)

I am developer with poor experience, however with strong academic CS background.
So please be patient where I am wrong somewhere.
As far I know, typescript can be executed on JS server and it works in this way in my case. Namely, I execute e2e tests with protactor (angular test framework).
I would like to debug it and check what methods was called during such execution on nodejs. To give you more details, I would like if (and possibly parameters) was invoked
waitForAngular(rootSelector, callback) method.
I know that it is possible to dump a variety of traces and debugging info from JVM, however I have no idea how can I do it with nodejs in my specific case.
Could you help me, please?
Around where you have your calls to waitForAngular (or any other code that you want to check), add a console.trace(), which will display a stack trace at that exact line of code.
You can read more about console.trace() and other console API methods at this document by the Chrome project (node.js uses the JS engine that Chrome uses): https://developers.google.com/web/tools/chrome-devtools/console/api#trace
You can sprinkle debugger statements in your code to stop execution which will allow you to step through your code. Similarly, you could start your Node process with the --inspect-brk argument to use Chrome DevTools to step through your code.

When to do Nashorn over Java Hooks?

I have a java application that does text processing.
Nashorn could be used to add customization just like hooks. So When should I use Nashorn and when should I use hooks? (assuming language doesn't matter)
It should be possible to write your hooks assuming java lambdas. This would allow Nashorn functions or Java functions to be used for your hooks. If you direct your question to nashorn-dev with specifics you will get more specific details.

Calling COM module from node.js

We have a closed COM engine we need to call from our node.js server.
Is there a package I can use to call this engine from node.js?
One way to do this is to build your own C++ extension to node.js.
This extension can use your COM component. However It looks complicated and time consuming to build an extension for node.js.
Check here fro more info http://nodejs.org/api/addons.html

Execute Javascript before launching the default XUL page

Have to execute scripts using spidermonkey(jagermonkey) javascript engine availalble within XULRunner.The javascript has some dependent Javascript libraries like requriejs/commonjs etc.
RequireJS provides documentation for Rhino/NodeJS javascript runtime environment.The documentation or testcases does not suggest anything about Spidermonkey scripting environment.
Is it possible to use requirejs with Spidermonkey?Any pointers on how to go about it ?
I am using the javascript runtime packaged within XULRunner 2.0.
For XULRunner in particular, you can take a look at the Firebug code -- it embeds requirejs with an adapter for running in XUL.

Resources