()
| 11 | * @returns Returns the present and dismiss methods in an array |
| 12 | */ |
| 13 | export function useIonLoading(): UseIonLoadingResult { |
| 14 | const controller = useController<LoadingOptions, HTMLIonLoadingElement>( |
| 15 | 'IonLoading', |
| 16 | loadingController, |
| 17 | defineCustomElement |
| 18 | ); |
| 19 | |
| 20 | const present = useCallback( |
| 21 | ( |
| 22 | messageOrOptions: string | (LoadingOptions & HookOverlayOptions) = {}, |
| 23 | duration?: number, |
| 24 | spinner?: SpinnerTypes |
| 25 | ) => { |
| 26 | if (typeof messageOrOptions === 'string') { |
| 27 | return controller.present({ |
| 28 | message: messageOrOptions, |
| 29 | duration, |
| 30 | spinner, |
| 31 | }); |
| 32 | } else { |
| 33 | return controller.present(messageOrOptions); |
| 34 | } |
| 35 | }, |
| 36 | [controller.present] |
| 37 | ); |
| 38 | |
| 39 | return [present, controller.dismiss]; |
| 40 | } |
| 41 | |
| 42 | export type UseIonLoadingResult = [ |
| 43 | { |
no test coverage detected