Reputation: 965
As I understand it uses Javascript engines to run javascript code on android/ios platform?
Also android/ios APIs (java, objective C) can be called with Nativescript javascript code, like this:
-On build Nativescript create metadata of all android/ios APIs -And leter when some api is called from javascript it looks for specific metadata and Nativescript run C++ to invoke android/ios API
Question is am I right? Feel free to correct me and add some additional things to understand this better?
Upvotes: 1
Views: 927
Reputation: 1486
Android:
Build-time all referenced classes.jar
s (those coming from plugins, support libraries, etc.) as well as the android.jar
SDK are parsed and binary metadata is written in 3 main chunks.
On app startup the first-level namespaces (android
, com
) are attached to the global scope in JavaScript. Then at any moment, while the app is running, when anything like android.a.b.c
is accessed the metadata chunks are read, built, javascript callbacks attached to the objects, and cached in the virtual machine, so that consecutive access to any members of that namespace is readily available.
Thanks to the metadata and callbacks that are attached to objects, the runtime knows when to create a new Java counterpart of an object (e.g. when you write 'new java.lang.Object()' in JavaScript) and link the JS instance with the one in Java world, this helps syncing the two Garbage Collectors (that of v8 and that of the android virtual machine on the Android device (dalvik/arm))
http://docs.nativescript.org/runtimes/android/advanced-topics/execution-flow
Upvotes: 3