-
Notifications
You must be signed in to change notification settings - Fork 0
Day 2 Components and Promises
Kobi Hari edited this page Mar 3, 2020
·
1 revision
| notepad | Componentization of notepad |
| pop-quiz-ex1 | Solution of class exercise |
| fun-with-promises | Introduction to promises in JS |
- We agreed that writing full scale applications in one component is difficult to maintain, which is why angular was built to support multi-component applications
- We created a
title-presnetercomponent that presents a title - We have used the
@InputDecorator to add input properties that may be passed through the HTML - We saw the difference between passing data using
[prop]="expression"syntax andprop="text"syntax. Where the first is used to bind data from the view model, and the second is used to pass a hard coded string. - We used the cli to auto-generate components using
ng g c components/component-name. See more details Here - We used the
@OutputDirective and theEventMitter<T>class to create our own events and raise them in our components - We used the
(event)="action()"Syntax to respond to an event in the container component - We used the
$eventkeyword to access event data
- Attached is a presentation and a video that present an exercise and its solution
- The presentation
- The Video
- We defined a promise as an object that tells us if an action that takes time has completed, and what is the result
- We saw that we can not "pull" that information, but rather have to use the
.thenand.catchmethods and provide callbacks that will be called when the promise completes - We saw how to create a promise using the
Promise Constructor. - We understood what
asyncandawaitkeywords do and how do they affect the compilation - We understood that the
.thenmethod, and theasynckeywords, also create promises, out of other promises - We saw how to ue
Promise.resolveto create a promise that is already completed when it is created - We saw how to use
Promise.allandPromise.raceto group promises together and wrap them in a single promise that returns all the results from all the promises or from the first one to complete.