Slide 1

Slide 1 text

No content

Slide 2

Slide 2 text

Smit Thakkar Lead Software Developer LendCypher

Slide 3

Slide 3 text

Flask-NSFW https://github.com/smitthakkar96

Slide 4

Slide 4 text

Agenda ● Getting started with Angular2 ● Angular2 setup ● Demo#1 Typeahead ○ Typeahead Classical Style - Response Order ○ Inefficiency with Classical Style ○ Typeahead : now with streams ■ Forms Control ■ Throttling ■ SwitchMap ■ View Binding and async pipe ● Demo#2 ○ Diving deep into RxJx

Slide 5

Slide 5 text

Environment used ● VS Code ● TypeScript ● NodeJs and NPM ● Angular CLI

Slide 6

Slide 6 text

What’s new in Angular2 ● Performance Improvements ● Mobile Support ● TypeScript ● No $Scope ● Component based programming ● Reactive Programming

Slide 7

Slide 7 text

Building Blocks of Angular2

Slide 8

Slide 8 text

Angular2 Components import { Component } from '@angular/core'; @Component({ selector: 'my-app', template: `

Hello {{name}}

` }) export class AppComponent { name = 'Angular'; } AngularJs Controllers var myApp = angular.module('myApp',[]); myApp.controller('DoubleController', ['$scope', function($scope) { $scope.double = function(value) { return value * 2; }; }]); Components

Slide 9

Slide 9 text

Providers Angular2 Provider import {Injectable} from 'angular2/core'; @Injectable() export class CarService { getCars = () => [ { id: 1, name: 'BMW' }, { id: 2, name: 'Suzuki' }, { id: 3, name: 'Volkswagen' } ]; } AngularJs Factory / Services var mainApp = angular.module("mainApp", []); mainApp.factory('MathService', function() { var factory = {}; factory.multiply = function(a, b) { return a * b } return factory; });

Slide 10

Slide 10 text

Pipes import { Pipe, PipeTransform } from '@angular/core'; @Pipe({name: 'capitalize'}) export class CapitalizePipe implements PipeTransform { transform(value: string, args: string[]): any { if (!value) return value; return value.replace(/\w\S*/g, function(txt) { return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase(); }); } }

Slide 11

Slide 11 text

Observables

Slide 12

Slide 12 text

What is RsJx? A Powerful implementation of observable. Hundreds of contributors Largely developed and maintained by Microsoft and Netflix It has all sets of combinators which you need.

Slide 13

Slide 13 text

An Observable is like a Stream (in many languages) and allows to pass zero or more events where the callback is called for each event. Often Observable is preferred over Promise because it provides the features of Promise and more. With Observable it doesn't matter if you want to handle 0, 1, or multiple events. You can utilize the same API in each case. Observable also has the advantage over Promise to be cancelable. If the result of an HTTP request to a server or some other expensive async operation isn't needed anymore, the Subscription of an Observable allows to cancel the subscription, while a Promise will eventually call the success or failed callback even when you don't need the notification or the result it provides anymore. Observable provides operators like map, forEach, reduce, ... similar to an array There are also powerful operators like retry(), or replay(), ... that are often quite handy. What are Observables?

Slide 14

Slide 14 text

Typeahead Classical Style

Slide 15

Slide 15 text

Typeahead Classical Style - Throttle

Slide 16

Slide 16 text

Typeahead Classical Style - Response Order

Slide 17

Slide 17 text

Out-of-Band and Side Effects

Slide 18

Slide 18 text

Inefficiency

Slide 19

Slide 19 text

Typeahead: now with streams

Slide 20

Slide 20 text

Angular2 Forms

Slide 21

Slide 21 text

Angular2 Forms Control

Slide 22

Slide 22 text

Angular2 Forms: Control Value Changes

Slide 23

Slide 23 text

Event Flow Step One: Throttling

Slide 24

Slide 24 text

Angular2 Http

Slide 25

Slide 25 text

Event Flow Step 2: Ticker Loader

Slide 26

Slide 26 text

Event Flow Step 3: SwitchMap

Slide 27

Slide 27 text

Event Flow 4: View Binding

Slide 28

Slide 28 text

Async Pipe

Slide 29

Slide 29 text

Event Flow 4: View Binding with Pipes

Slide 30

Slide 30 text

Q&A Queries and Issues are heartily welcome

Slide 31

Slide 31 text

Thank You!

Slide 32

Slide 32 text

[email protected] github.com/smitthakkar96 facebook.com/geekysmit