User class and object-oriented programming

So far, we have only worked with interfaces to represent data, and we still want to continue using interfaces when passing data around various components and services. However, there's a need to create a default object to initialize a BehaviorSubject. In Object-oriented Programming (OOP), it makes a lot of sense for the User object to own this functionality instead of a service. So, let's implement a User class to achieve this goal.

Inside the user/user folder, define an IUser interface and a User class provided in UserModule:

src/app/user/user/user.tsimport { Role } from '../../auth/role.enum'export interface IUser {  id: string  email: string  name: {    first: string    middle: string    last: string  } picture: ...

Get Angular 6 for Enterprise-Ready Web Applications now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.