February 2019
Beginner
694 pages
18h 4m
English
Backbone also allows us to use ECMAScript 5 capabilities to define getters and setters for Backbone.Model classes, as follows:
interface ISimpleModel { name: string; id: number;}class SimpleModel extends Backbone.Model implements ISimpleModel { get name() { return this.get('name'); } set name(value: string) { this.set('name', value); } get id() : number { return this.get('id'); } set id(value: number) { this.set('id', value); }}
Here, we have defined an interface with two properties, named ISimpleModel. We then define a SimpleModel class that derives from Backbone.Model, and also implements the ISimpleModel interface. We then have ES5 getters and setters for our name and id properties. Backbone uses class attributes to ...
Read now
Unlock full access