Polishing the implementation

We're missing a few important pieces in our model and service to really polish off our implementation. Let's start with handling completion and error conditions with our track player instances. Open TrackPlayerModel at app/modules/shared/models/track-player.model.ts and add the following:

...export interface IPlayerError {  trackId: number;  

error: any;}export class TrackPlayerModel implements ITrackPlayer {    ...  private _completeHandler: (number) => void;  private _errorHandler: 

(IPlayerError) => void;  ...  public load(    track: ITrack,     

complete: (number) => void,     error: (IPlayerError) => void  ): 

Promise<number> {    return new Promise((resolve, reject) => {      ...      

this._completeHandler = complete; this._errorHandler = ...

Get NativeScript for Angular Mobile Development 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.