- 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];
}
}
}
}
推薦閱讀
- C++面向對象程序設計(第三版)
- UI圖標創意設計
- SoapUI Cookbook
- What's New in TensorFlow 2.0
- 零基礎學Scratch少兒編程:小學課本中的Scratch創意編程
- C#程序設計(慕課版)
- JS全書:JavaScript Web前端開發指南
- 精通Python自然語言處理
- Python機器學習算法: 原理、實現與案例
- ASP.NET開發與應用教程
- Microsoft Azure Storage Essentials
- Learning PHP 7
- OpenCV 3 Blueprints
- Learning Splunk Web Framework
- HTML+CSS+JavaScript網頁制作:從入門到精通(第4版)