Get value from NodeJs package in C++

The GetValue method is used to retrieve the result of an operation performed by the Javonet API.

// use Activate only once in your app

// create called runtime context
auto calledRuntime = Javonet::InMemory()->Nodejs();

// construct an invocation context - this invocationContext in non-materialized 
auto invocationContext = calledRuntime->GetType("Math")->InvokeStaticMethod("abs", -50);

// execute invocation context - this will materialize the invocationContext
auto response = invocationContext->Execute();

// get value from response
auto result = std::any_cast<int>(response->GetValue());

// write result to console
std::cout << result << std::endl;

Commands are becoming nested through each invocation of methods on Invocation Context. Each invocation triggers the creation of new Invocation Context instance wrapping the current command with new parent command valid for invoked method.

Developer can decided on any moment of the materialization for the context taking full control of the chunks of the expression being transferred and processed on target runtime.