2. Globalcode – Open4education
O que é NativeScript?
É um runtime para construir e executar Apps
Nativos para iOS e Android com um único
código base em JavaScript
(In 2016)
3. Globalcode – Open4education
Não é PhoneGap…
... nem Ionic
Componentes Reais e Nativos
Não usa o DOM
Não usa HTML como se fossem componentes nativos
Usa componentes Nativos
•Sem DOM
•Uis Nativas
!=
4. Globalcode – Open4education
Não é Xamarin
Não faz Cross Compiling
Acesso 100% nativo as APIs de forma direta
Não é dependente de código .Net
Não faz cross compilation
!=
5. Globalcode – Open4education
Não é React Native
Não usa ObjectiveC, Swift ou Java
{n} Javascript tem 100% de acesso nativo e imediato às
APIs e UIs assim que elas são lançadas
Acesso direto às APIs
com JS
!=
11. Globalcode – Open4education
Use código pronto
Use milhares de plugins do NPM
Use controles nativos do Cocoapods ou Android Arsenal
12. Globalcode – Open4education
Arquitetura Flexível
Javascript
Escreva seu
aplicativo usando
Javascript
TypeScript
Aproveite ao máximo a
Orientação a Objetos e
verificação de erros
Angular
Arquitete sua aplicação e
reutilize o código escrito
para Web no Mobile
I mention this because, in today’s world, where 10 JavaScript frameworks have been created since I started this presentation, that it’s important to pick an innovative and stable options
I'll give your brain a minute or two to parse this, because yes, this JavaScript code instantiates a Java android.text.format.Time() object, calls its set() method, then logs the return value of its format() method, which is the string "01/01/15".
This JavaScript code instantiates an Objective-C UIAlertView class, sets its message property, and then calls its addButtonWithTitle() and show() methods. When you run a NativeScript iOS app with this code you'll see the alert below:
The call dispatcher executes the call with a dual result:
•On the Android Side: we get a new instance of the native File class
•On the NativeScript Side: we get a custom JavaScript Object serving as a proxy to the native Android’s object
When a method is called on this proxy it is delegated to the underlying native object.
<Before the next slide>
This is the foundation of the NativeScript framework.
The next logical step was to create a platform agnostic abstraction layer.
It is really great that you can access native APIs straight form JavaScript.
But I can hear you think. … this still doesn’t solve the problem of me having to learn all those Platform APIs.
But this is just the foundation of the NativeScript framework.
NativeScript comes equipped with modules that provide cross-platform functionality.
There are dozens of them and they’re easy to write yourself.
NativeScript modules follow Node module’s conventions (CommonJS).