Bram's Dev Blog

home

100 Days of Code Day 39 - Angular tour of heroes pt6

27 Sep 2018

Angular - Tour of heroes pt6 on HTTP

Very often, the statements get long as multiple function calls are chained after eachother. I’m wondering if you work on a bigger project like DSpace, where other people write the code that you need to continue on, what this does for readability. For example:

/** POST: add a new hero to the server */
addHero (hero: Hero): Observable<Hero> {
  return this.http.post<Hero>(this.heroesUrl, hero, httpOptions).pipe(
    tap((hero: Hero) => this.log(`added hero w/ id=${hero.id}`)),
    catchError(this.handleError<Hero>('addHero'))
  );
}

Following seems important to remember in RxJs & working with observables: If you neglect to subscribe(), the service will not send the delete request to the server! As a rule, an Observable does nothing until something subscribes!

Another convention: The $ is a convention that indicates heroes$ is an Observable, not an array.

The last piece of the Angular Tour of Heroes puzzle is now in place: the search feature that uses the RxJs Async pipeline. Again amazed at the simplicity of the resulting code, but clear that there’s a lot going on under the hood that I want to get more familiar with.

Early start - late end

Did 20 minutes in the morning and finished with 40 minutes right before going to bed.

Day 40 Plan

I’ll start with ng-book 2. Not sure if I’ll go into every single tutorial in there, but hope that this will give me a little bit more depth.

Future days - DSpace 7 Angular

Future days - Analyzer.atmire.com work

Future Days - Productivity

Future days - Jekyll http://bram-atmire.github.io/ site

Future Days - Atmire.com work

Investigate and work on search engine optimization (SEO) for the main atmire.com website.

Future Days - Learning just for learning

Sustainability - Raising the stakes - Looking for sponsors (unchanged)

I have raised the stakes by

This way, every day would be a win. These are the rules that I’ll apply:

  1. I can anticipate or fix a lost day by doing an hour extra the day before, or an hour extra the day after. In theory this means I can maximally compensate a streak of 2 missed days.
  2. Goal is to have a steady frequency, so I can’t just do 8h on a sunday to get myself off the hook for the next 7 days.
  3. Sponsor commitments are fully voluntarily: any sponsor can back out at any time.
  4. My commitment is fully voluntarily: if I want to change the rules or back out, I can at any time.

This month, these are already days that will be very tough:

So that’s already a lot of exposure to potentially missed days.

I will raise the stakes this way and gather money for Charity:Water. Let me know if you want to sponsor me and for how much per completed day in September. September 1st is the first successfully completed day.

September tracking

Will only log the failed days here. No failed days so far.

Thanks to the following sponsors!

  1. Jan & Hilde: €2 per successful day (Yes, these are my parents)