Created
May 11, 2020 07:32
-
-
Save dilipsuthar97/69cba233e03c3e484abf32b7c6000e98 to your computer and use it in GitHub Desktop.
Android Native Module wrapper for ReactNative -index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// @flow | |
import { NativeModules } from 'react-native'; | |
const { MyLibrary } = NativeModules; | |
interface ToastOptions { | |
message: string; | |
duration?: number; | |
} | |
interface IToast { | |
LENGTH_SHORT: number; | |
LENGTH_LONG: number; | |
show: (toastOptions: ToastOptions) => void; | |
} | |
// Toast | |
const Toast: IToast = { | |
LENGTH_SHORT: MyLibrary.TOAST_SHORT, | |
LENGTH_LONG: MyLibrary.TOAST_LONG, | |
show(toastOptions: ToastOptions) { | |
MyLibrary.showToast(toastOptions); | |
}, | |
}; | |
export { Toast }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment