@ionic/angular
Advanced tools
Comparing version 0.0.2-6 to 0.0.2-7
import { AlertOptions } from '@ionic/core'; | ||
export declare class AlertController { | ||
create(opts?: AlertOptions): any; | ||
create(opts?: AlertOptions): AlertProxy; | ||
} | ||
@@ -9,7 +9,9 @@ export declare function getAlertProxy(opts: AlertOptions): { | ||
opts: AlertOptions; | ||
present: () => Promise<void>; | ||
dismiss: () => Promise<void>; | ||
present: () => Promise<any>; | ||
dismiss: () => Promise<any>; | ||
onDidDismiss: (callback: (data: any, role: string) => void) => void; | ||
onWillDismiss: (callback: (data: any, role: string) => void) => void; | ||
}; | ||
export declare function present(alertProxy: AlertProxyInternal): Promise<void>; | ||
export declare function dismiss(alertProxy: AlertProxyInternal): Promise<void>; | ||
export declare function present(alertProxy: AlertProxyInternal): Promise<any>; | ||
export declare function dismiss(alertProxy: AlertProxyInternal): Promise<any>; | ||
export declare function loadOverlay(opts: AlertOptions): any; | ||
@@ -19,2 +21,4 @@ export interface AlertProxy { | ||
dismiss(): Promise<void>; | ||
onDidDismiss(callback: (data: any, role: string) => void): void; | ||
onWillDismiss(callback: (data: any, role: string) => void): void; | ||
} | ||
@@ -25,4 +29,7 @@ export interface AlertProxyInternal extends AlertProxy { | ||
state: number; | ||
element: HTMLIonAlertElement; | ||
onDidDismissHandler?: (data: any, role: string) => void; | ||
onWillDismissHandler?: (data: any, role: string) => void; | ||
} | ||
export declare const PRESENTING = 1; | ||
export declare const DISMISSING = 2; |
@@ -15,7 +15,29 @@ import { Injectable } from '@angular/core'; | ||
present: function () { return present(this); }, | ||
dismiss: function () { return dismiss(this); } | ||
dismiss: function () { return dismiss(this); }, | ||
onDidDismiss: function (callback) { | ||
this.onDidDismissHandler = callback; | ||
}, | ||
onWillDismiss: function (callback) { | ||
this.onWillDismissHandler = callback; | ||
}, | ||
}; | ||
} | ||
export function present(alertProxy) { | ||
alertProxy.state = PRESENTING; | ||
return loadOverlay(alertProxy.opts).then((alertElement) => { | ||
alertProxy.element = alertElement; | ||
const onDidDismissHandler = (event) => { | ||
alertElement.removeEventListener(ION_ALERT_DID_DISMISS_EVENT, onDidDismissHandler); | ||
if (alertProxy.onDidDismissHandler) { | ||
alertProxy.onDidDismissHandler(event.detail.data, event.detail.role); | ||
} | ||
}; | ||
const onWillDismissHandler = (event) => { | ||
alertElement.removeEventListener(ION_ALERT_WILL_DISMISS_EVENT, onWillDismissHandler); | ||
if (alertProxy.onWillDismissHandler) { | ||
alertProxy.onWillDismissHandler(event.detail.data, event.detail.role); | ||
} | ||
}; | ||
alertElement.addEventListener(ION_ALERT_DID_DISMISS_EVENT, onDidDismissHandler); | ||
alertElement.addEventListener(ION_ALERT_WILL_DISMISS_EVENT, onWillDismissHandler); | ||
if (alertProxy.state === PRESENTING) { | ||
@@ -27,7 +49,12 @@ return alertElement.present(); | ||
export function dismiss(alertProxy) { | ||
return loadOverlay(alertProxy.opts).then((alertElement) => { | ||
alertProxy.state = DISMISSING; | ||
if (alertProxy.element) { | ||
if (alertProxy.state === DISMISSING) { | ||
return alertElement.dismiss(); | ||
return alertProxy.element.dismiss(); | ||
} | ||
}); | ||
} | ||
// either we're not in the dismissing state | ||
// or we're calling this before the element is created | ||
// so just return a resolved promise | ||
return Promise.resolve(); | ||
} | ||
@@ -42,2 +69,4 @@ export function loadOverlay(opts) { | ||
export const DISMISSING = 2; | ||
const ION_ALERT_DID_DISMISS_EVENT = 'ionAlertDidDismiss'; | ||
const ION_ALERT_WILL_DISMISS_EVENT = 'ionAlertWillDismiss'; | ||
//# sourceMappingURL=alert-controller.js.map |
@@ -1,1 +0,1 @@ | ||
[{"__symbolic":"module","version":4,"metadata":{"AlertController":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable"}}],"members":{"create":[{"__symbolic":"method"}]}},"getAlertProxy":{"__symbolic":"function","parameters":["opts"],"value":{"__symbolic":"error","message":"Expression form not supported","line":16,"character":8}},"present":{"__symbolic":"function","parameters":["alertProxy"],"value":{"__symbolic":"error","message":"Function call not supported","line":25,"character":43}},"dismiss":{"__symbolic":"function","parameters":["alertProxy"],"value":{"__symbolic":"error","message":"Function call not supported","line":33,"character":43}},"loadOverlay":{"__symbolic":"function"},"AlertProxy":{"__symbolic":"interface"},"AlertProxyInternal":{"__symbolic":"interface"},"PRESENTING":1,"DISMISSING":2}}] | ||
[{"__symbolic":"module","version":4,"metadata":{"AlertController":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable"}}],"members":{"create":[{"__symbolic":"method"}]}},"getAlertProxy":{"__symbolic":"function","parameters":["opts"],"value":{"__symbolic":"error","message":"Expression form not supported","line":16,"character":8}},"present":{"__symbolic":"function"},"dismiss":{"__symbolic":"function"},"loadOverlay":{"__symbolic":"function"},"AlertProxy":{"__symbolic":"interface"},"AlertProxyInternal":{"__symbolic":"interface"},"PRESENTING":1,"DISMISSING":2}}] |
{ | ||
"name": "@ionic/angular", | ||
"version": "0.0.2-6", | ||
"version": "0.0.2-7", | ||
"description": "Angular specific wrappers for @ionic/core", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
32340
375