Skip to content

Commit

Permalink
fix(indexappcontent): Return observable for onItemPressed
Browse files Browse the repository at this point in the history
  • Loading branch information
NiklasMerz committed Oct 1, 2017
1 parent 536a906 commit 05962d2
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/@ionic-native/plugins/index-app-content/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { Injectable } from '@angular/core';
import { Plugin, Cordova, IonicNativePlugin } from '@ionic-native/core';
import { Observable } from 'rxjs/Observable';

declare var window: any;

export interface IndexItem {
domain: string;
Expand Down Expand Up @@ -95,12 +98,18 @@ export class IndexAppContent extends IonicNativePlugin {
/**
* If user taps on a search result in spotlight then the app will be launched.
* You can register a Javascript handler to get informed when this happens.
* @param {IndexItem} Clicked Item
* @return {Promise<any>} Returns promise
* @returns {Observable<any>} returns an observable that notifies you when he user presses on the home screen icon
*/
@Cordova()
onItemPressed(payload: IndexItem) {
return;
onItemPressed(): Observable<any> {
return new Observable(observer => {
if (window.plugins.indexAppContent) {
window.plugins.indexAppContent.onItemPressed = observer.next.bind(observer);
} else {
observer.error('Index-App-Content plugin is not available.');
observer.complete();
}
});
}

/**
Expand Down

0 comments on commit 05962d2

Please sign in to comment.