O'Reilly logo

NativeScript for Angular Mobile Development by Nathanael J. Anderson, Nathan Walker

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 = ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required