Skip to content

Instantly share code, notes, and snippets.

@dilipsuthar97
Created May 11, 2020 07:32
Show Gist options
  • Save dilipsuthar97/69cba233e03c3e484abf32b7c6000e98 to your computer and use it in GitHub Desktop.
Save dilipsuthar97/69cba233e03c3e484abf32b7c6000e98 to your computer and use it in GitHub Desktop.
Android Native Module wrapper for ReactNative -index.ts
// @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