- NativeScript for Angular Mobile Development
- Nathan Walker Nathanael J. Anderson
- 185字
- 2021-07-02 18:41:48
A shared model for our data
Before we go about creating our services, let's create an interface and model implementation for the core piece of data our app will be using. The TrackModel will represent a single track with the following:
- filepath: (to the local file)
- name: (for our view)
- order: Position (for the view listing of tracks)
- volume: We want our player to be able to mix different tracks together with different volume level settings
- solo: Whether we want to hear just this track in our mix
We will also add a convenient constructor to our model, which will take an object to initialize our model with.
Create app/modules/core/models/track.model.ts, since it will be shared across both our player and recorder:
export interface ITrack {
filepath?: string;
name?: string;
order?: number;
volume?: number;
solo?: boolean;
}
export class TrackModel implements ITrack {
public filepath: string;
public name: string;
public order: number;
public volume: number = 1; // set default to full volume
public solo: boolean;
constructor(model?: any) {
if (model) {
for (let key in model) {
this[key] = model[key];
}
}
}
}
推薦閱讀
- Web程序設(shè)計(jì)及應(yīng)用
- Rust編程:入門、實(shí)戰(zhàn)與進(jìn)階
- Java 9 Programming Blueprints
- Java Web程序設(shè)計(jì)
- Data Analysis with Stata
- Building Minecraft Server Modifications
- Visual FoxPro程序設(shè)計(jì)習(xí)題集及實(shí)驗(yàn)指導(dǎo)(第四版)
- C#開發(fā)案例精粹
- Java程序設(shè)計(jì)案例教程
- Scratch3.0趣味編程動(dòng)手玩:比賽訓(xùn)練營
- Node學(xué)習(xí)指南(第2版)
- ArcGIS for Desktop Cookbook
- Learning Docker Networking
- Java圖像處理:基于OpenCV與JVM
- JavaScript從入門到精通(視頻實(shí)戰(zhàn)版)