Typescript-201 Flashcards
How can we define optional arguments?
function
What are pipes used for?
Pipe asre used to format the data from src and bing them to the directive
Which design principle does Service resembles?
SRP Single Repsoncibility Principle
What is system js used for?
As a config & module loader
What is app.component.ts
It is a standard way of specifying the bootstrapping class.
What is @Component?
It is imported from @angular/core and it is used to bootstrap the class in app.component.ts
What is the syntax and way of using @Component?
First import the component from @angular/core
While importing need not to use @ sign as @ mostly specifies that at the notation & aLso if you want to make a class that could be used else where for @
import {component} from ‘@angular/core’
// The @Component takes an object in parenthesis to //invoke @Component({ // the below are must defined keys of //@Component selector : ápp', template : 'html code or path to html file'
})
export class AppComponent{ } // Make it available
What is RxJS
Reactive Extension for JS
What is RxJS used for?
Its a programming with emitting data, sync or async
What is observable in RxJS?
Any emitting data from any src(array, api, object) is Observable
Does Observable automatically notifies the observer?
Yes the Observable notifies the observer when data starts emitting or arrive
What is the difference between Observable & Promise?
The promise gets the data one time, and you need to invoke the method again, with observable it will emit multiple times
Can you write a simple Observable code?
var obs = Rx.Observale.of(10); obs.subscribe(function(d){ console.log(d); // prints 10 });
Does Observable has the capability to invoke the error or success block? Say with E.g.
Yes
var obs = Rx.Observable.of(10); obs.subscribe( function(d){ d= d+d; }, function(e){
console.log(ërror’’);
}, function(){
console.log(“success”);
}
);
so all three goes into the paren and as args, the success case wont have any args
What does from operator does?
It helps convert array into Observable