You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Dec 4, 2017. It is now read-only.
Put will be used to update an individual hero. Its structure is very similar to Post requests. The only difference is that we have to change the url slightly by appending the id of the hero we want to update.
212
+
Put will be used to update an individual hero. Its structure is very similar to Post requests. The only difference is that we have to change the URL slightly by appending the id of the hero we want to update.
In order to differentiate between add and edit we are adding a check to see if an id is passed in the url. If the id is absent we bind `HeroDetailComponent` to an empty `Hero` object. In either case, any edits made through the UI will be bound back to the same `hero` property.
262
+
In order to differentiate between add and edit we are adding a check to see if an id is passed in the URL. If the id is absent we bind `HeroDetailComponent` to an empty `Hero` object. In either case, any edits made through the UI will be bound back to the same `hero` property.
263
263
264
264
:marked
265
265
Add a save method to `HeroDetailComponent` and call the corresponding save method in `HeroesService`.
@@ -357,12 +357,13 @@ block review
357
357
### Let's see it
358
358
Here are the fruits of labor in action:
359
359
figure.image-display
360
-
img(src='/resources/images/devguide/toh/toh-http.anim.gif'alt="Heroes List Editting w/ HTTP")
360
+
img(src='/resources/images/devguide/toh/toh-http.anim.gif'alt="Heroes List Editing w/ HTTP")
361
361
362
-
blockobservables-section
363
362
:marked
364
-
## Observables
363
+
## !{_Observable}s
365
364
365
+
blockobservables-section-intro
366
+
:marked
366
367
Each `Http` method returns an `Observable` of HTTP `Response` objects.
367
368
368
369
Our `HeroService` converts that `Observable` into a `Promise` and returns the promise to the caller.
@@ -384,59 +385,78 @@ block observables-section
384
385
A single result in the form of a promise is easy for the calling component to consume
385
386
and it helps that promises are widely understood by JavaScript programmers.
386
387
388
+
:marked
387
389
But requests aren't always "one and done". We may start one request,
388
-
then cancel it, and make a different request ... before the server has responded to the first request.
389
-
Such a _request-cancel-new-request_ sequence is difficult to implement with *promises*.
390
-
It's easy with *observables* as we'll see.
390
+
then cancel it, and make a different request before the server has responded to the first request.
391
+
Such a _request-cancel-new-request_ sequence is difficult to implement with *!{_Promise}s*.
392
+
It's easy with *!{_Observable}s* as we'll see.
391
393
392
394
### Search-by-name
393
395
We're going to add a *hero search* feature to the Tour of Heroes.
394
-
As the user types a name into a search box, we'll make repeated http requests for heroes filtered by that name.
396
+
As the user types a name into a search box, we'll make repeated HTTP requests for heroes filtered by that name.
395
397
396
398
We start by creating `HeroSearchService` that sends search queries to our server's web api.
0 commit comments