Deutschland nimmt die Titelverteidigung in Angriff

Top-Favorit Frankreich? Hat sich zu einem 2:1 gegen Australien gemüht. Argentinien mit Lionel Messi? Kam gegen Island nicht über ein 1:1 hinaus. Und jetzt ist Deutschland am Zug! Die…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




Angular and Rxjs

Angular:

Angular is a framework for building client applications in HTML and either JavaScript or a language like TypeScript that compiles to JavaScript.

Angular Architecture

2. Component

Component is function, decorator by key word “@Component”, and metadata contains: CSS selector, HTML Template, CSS styles(optional).

2.1 Metadata

In this example, the code between “{…}” is a meta data object. Metadata tells Angular how to process a class.

When we want to access other components, we can just use CSS selector to do it.

Access other components

2.2 Data Binding

Data binding

2.3 Life Cycle

Component life cycle

3. Dependency Injection

Dependency injection is a way to supply a new instance of a class with the fully-formed dependencies it requires. Most dependencies are services. Angular uses dependency injection to provide new components with the services they need.

Service
Component

The injector relies on providers to create instances of the services that the injector injects into components and other services.

When a component at the bottom requests a dependency, Angular tries to satisfy that dependency with a provider registered in that component’s own injector. If the component’s injector lacks the provider, it passes the request up to its parent component’s injector. If that injector can’t satisfy the request, it passes it along to its parent component’s injector. The requests keep bubbling up until we find an injector that can handle the request or run out of component ancestors. If we run out of ancestors, Angular throws an error.

Rxjs:

streams

Front end developing is different from backend developing. The mind of it is ‘everything is a stream’. It was because every operation from a user can be seen as a data of a stream. In this way it’s easier to handle these data. For example in an FPS game, it’s hard to do the data statics. Questions such as ‘how many shot in one game?’, ‘what’s the hit rate of a player?’ are pretty hard to handle in the traditional design. But using stream can hanld these problems well. A stream is simply a collection that arrives over time. Reactive programming is programming with asynchronous data streams. RxJS is one of the hottest libraries in web development for reactive programming.

Every thing is a stream

2. Observable

In RxJS, you represent asynchronous data streams using observable sequences or also just called observables. Observables are very flexible and can be used using push or pull patterns. In JavaScript we may distinguish between three of them:

Generator, Observable, Function, Promis

Promises: for returning single asynchronous results,
Functions: for single results, and
Generators: for providing iterators.

3. Subject

Observable is a data pro­ducer. Subject is not only a data pro­ducer but also a data consumer. There are 3 different kinds of Subject:

4. Rxjs Operations

Add a comment

Related posts:

The Truth Hurts

And a background GC process made sure they were in sync, because the “sync” method had a bug(s?) in it somewhere. (Incidentally, there was a perfectly logical for pretty much each of the above steps…

Childcare Leaders Endure

I know the word endurance sometimes is not seen in the most enlightening light, but it can be when it is connected with achievement. According to Merriam-Webster endurance means the ability to…