samedi 30 juillet 2016

Avoiding duplication of an if/else statement

I am buliding an application that should have some walk through only when the user is loggedin for the first time.

Each page of the application has its own implementation of how to show the walk through

I don't want to ask on every page if (firstTime) ... How can I avoid that duplication of that statement, what is the right design pattern?

It's an Angular 2 application so each page is a component... I thought it will be good to create a base component and on his ngOnInit ask that if. And then in the children implement on each one the same function. Is it possible to extend components?

Aucun commentaire:

Enregistrer un commentaire