2/21/18

How To Remove Property From Object Using ES6 Destructor

This trick i learned from Todd Motto`s grate ngrx tutorial:
Lets say you have javascript object like here:

  {
    "1": "koko",
    "2": "shoko"  
  }

And you need to remove only one property from it, say only the first one, which key is "1".
Yes, you can do it using old good "delete" command, but instead i recommend to take advantage of "ES6 destuctors" and spread
Destructors are way to set variables from existing object in one single command.
Spread command is for splitting the object (or array) properties to different variables.
By combining those to ES6 features we can do the trick:
Which is much more nice

2/13/18

What Is This "Tap" Thing In Rxjs?

In the bank of Jordan river, in the Moab land, Moses wished to explain his testament to Sons of Israel and that`s what is he said:
I'm looking at great angular-ngrx-material-starter repo of great guy named Tom Trajan
And here is the code of "auth.effects" file, where you can clear see the usage of "tap" operator:

  @Effect({ dispatch: false })
  login(): Observable {
    return this.actions$
      .ofType(AuthActionTypes.LOGIN)
      .pipe(
        tap(action => // <-- code="" here="" isauthenticated:="" see="" tap="" the="" thing="" this.localstorageservice.setitem="" true="">
So what is this "tap"(lettable operator) thing doing???

Documentation

When looking into rxjs docs you can see that "tap" is newer version of "do" operator.
Also you can see following sentence: invokes an action upon graceful or exceptional termination of the observable sequence.
That means - if you want something to be done regardless of outcome of observable you can do it with "tap"

Example

All the places in he code which only taking care of storing the payload(and not trying to modify the outcome of observable ) in the localstorage making usage if "tap":

  @Effect({ dispatch: false })
  persistTodos(): Observable {
    return this.actions$
      .ofType(TodosActionTypes.PERSIST)
      .pipe(
        tap((action: ActionTodosPersist) =>
          this.localStorageService.setItem(TODOS_KEY, action.payload.todos)
        )
      );
  }

When observable outcome is somehow modified - the "map" operator comes to the stage:

  @Effect()
  loadPizzas$ = this.actions$.ofType(pizzaActions.LOAD_PIZZAS).pipe(
    switchMap(() => {
      return this.pizzaService
        .getPizzas()
        .pipe(
          map(pizzas => new pizzaActions.LoadPizzasSuccess(pizzas)),
          catchError(error => of(new pizzaActions.LoadPizzasFail(error)))
        );
    })
  );

2/5/18

Most Important Skill In Your Career As A Programmer

Good morning to everyone of gs500coder blog readers!
As you can see i have published a lot of posts which could help you to improve your skills as a programmer, by learn some cool techniques in some programming domain (like CSS or Javascript)
But in this post i want to share some insight that became for me more and more clearer as my experience grows:
The most important skill for a programmer (even more important than advanced knowledge in his discipline) - is to be a good team player.

Team Player!? What do yo mean by that?

Yes. Like like in soccer game - one team member cannot win without collaboration of other team members (no matter how skilled he is), programmer must know how to work within a team. It may sound strange to some, but i found this to-be-a-good-teamplayer task even harder than any other programming tasks i do

Give Us Some Points Please

Since i not consider myself an expert at this field, here first (and last cause it is not easy)rule - i think a programmer should try to follow: Be a communicative person. (A person with whom other team members will feel convenient to talk, eat a lunch or share their thoughts ) That means also to be (no matter how frustrated you feel) friendly. Nobody likes angry people, Nobody likes to be blamed (no matter if it justified or not) Try to be optimistic man who gives to his mates/managers a feeling of hope
A good feeling should be a main measure of your success

Happiness Is Good

As far as i heard, there are scientific researches that prove: happier people is also healthier.
Thus - to be in a good relationship with everybody will not only benefit your work - it will benefit your health

2/1/18

Rxjs Pipe Operator (Nothing To Be Afraid Of)

Recently i noticed following code while going through Todd Motto NGRX tutorial:

  @Effect()
  loadPizzas$ = this.actions$.ofType(pizzaActions.LOAD_PIZZAS)
   .pipe(  // <=look here!!!
    switchMap(() => {
      return this.pizzaService
        .getPizzas()
        .pipe(
          map(pizzas => new pizzaActions.LoadPizzasSuccess(pizzas)),
          catchError(error => of(new pizzaActions.LoadPizzasFail(error)))
        );
    })
  );

Since i respect Todd Motto very much i decided to look what this pipe thing is about:
After pointing on "pipe" word and clicking "F12" key (in VSCode), that is what i got:
So this pipe is rxjs one of methods which exists on Observable object, like for example toPromise or subscribe
So what is it doing?
According to Rxjs documentation :

pipe method сan be used to compose the operators in similar manner to what you're used to with dot-chaining (shown below).

Thas all - compose various operators, like "switchMap" ,"map" or "catchError" which currently (in Rxjs 5.5) could be used as standalone operators instead of methods on an observable(pipeable)

Thats IT

Getting started with docker

It is very simple to get started usig docker. All you need to do-is download the docker desktop for your system Once you get docker syste...