Data models,
Interfaces, binding to view

we've got kmeetup on production!

http://kmeetup.herokuapp.com/

{
  title: 'Angular 2 - ngrx essentials',
  slug: 'angular-2-ngrx-essentials',
  description: 'Angular2 ngrx intro - workshop 
    about implementing ngrx, the redux implementaion 
    in Angular2 - Store, time travaller, dispacher and more',
  group: {
    slug: 'angular-js',
    name: 'kNG2',
    createdOn: 1468431000
  },
  location: 'Conf-TLV',
  createdOn: 1468431000,
  organizer: {
    firstName: 'dvir',
    lastName: 'hazout',
    email: 'dvir.hazut@kaltura.com'
  },
  startTime: 1468431000,
  endTime: 1468431000,
  attending: {
    rsvpState: true,
    total: 10,
    trend: 0,
    users: [
    {
      firstName: 'dvir',
      lastName: 'hazout',
      email: 'dvir.hazut@kaltura.com'
    }]
  }
}
  1. identify entities
  2. create interfaces
  3. create classes implementing
    the interfaces
export interface INTERFACE_NAME {
  stringProperty: string,
  numProperty: number,
  boolProperty: boolean,
  arrayOfType: Array<CUSTOM_TYPE_INTERFACE>,
  customType: CUSTOM_TYPE_INTERFACE
}

Interfaces

export class DATA_MODEL_CLASS implements INTERFACE_NAME {    
  stringProperty: string;
  numProperty: number;
  boolProperty: boolean;
  arrayOfType: Array<CUSTOM_TYPE_INTERFACE>;
  customType: CUSTOM_TYPE_INTERFACE;

  constructor(obj) {
    this.stringProperty = obj.stringProperty;
    ...
  }
}

Class implements interface

Data models & Interfaces

By Dvir Hazout

Data models & Interfaces

  • 589