Building React Native Apps with Angular2
Dani Akash S.
Software Engineer, RedBlackTree.
Angular 2
Supported Platforms
Electron
Build cross platform desktop Apps using web technologies.
Ionic
Build Hybrid Mobile Apps using web technologies.
Nativescript
Build truly Native mobile apps using Angular, Typescript and Javascript.
React Native
Build Native mobile apps using Angular and react-native-renderer in React-Native.
Angular 2 Supported Platforms
React Native as a platform
Interfacing JS with the Native Bridge.
Angular 2 and React Native Architecture
Typescript
Static Typing for Javascript.
// Named function
function add(x, y) {
return x + y;
}
// Anonymous function
let myAdd = function(x, y) {
return x+y;
};
// Named function
function add(x: number, y: number): number {
return x + y;
}
// Anonymous function
let myAdd = function(x: number, y: number): number {
return x+y;
};
Why Typescript?
Setting up your Dev Environment
Installation
Clone Angular2 React Native Seed
https://github.com/mlaval/angular2-react-native-seed.git
> npm install -g gulp react-native-cli typings
> cd angular2-react-native-seed && npm install
> gulp init
> gulp start.ios (or) gulp start.android
Install a TS friendly text editor
Angular 2
Modules
An NgModule is a class decorated with @NgModule metadata.
Modules are a great way to organize an application and extend it with capabilities from external libraries.
Many Angular libraries are modules (such as FormsModule, HttpModule, and RouterModule). Many third-party libraries are available as NgModules
Every Angular app has at least one module class, the root module. You bootstrap that module to launch the application.
Components
Component is a class decorated with @Component metadata.
Components are the main way we build and specify elements and logic on the page, through both custom elements and attributes that add functionality to our existing components.
In react-native Router uses Component as the main Identifier.
Services
Services are JavaScript functions that are responsible for doing a specific task.
Angular services are injected using Dependency Injection mechanism and include the value, function or feature which is required by the application.
Services are like the ‘Redux’ part of your React Native application.
Thank You!
Connect with me on:
in.linkedin.com/in/daniakash
@DaniAkashS
Source Code for the todolist app - https://goo.gl/1wW2Ic