Skip to content

Instantly share code, notes, and snippets.

@tmikeschu
Last active October 11, 2019 18:43
Show Gist options
  • Save tmikeschu/e6a6cb268cdc424247a9fc86dd34906c to your computer and use it in GitHub Desktop.
Save tmikeschu/e6a6cb268cdc424247a9fc86dd34906c to your computer and use it in GitHub Desktop.
// goal is to be able to extend the notification payload type depending on the server implementation
// library
interface PushNotification {
// ...
}
interface PushNotificationOptions<T> {
// ...
onNotification?: (notification: PushNotification & T) => void;
// ...
}
interface PushNotification {
configure<T>(options: PushNotificationOptions<T>): void;
}
// end library
// unique implementation
export interface EMSPushNotification {
// ...
}
const NotificationsHandler = () => {
const notificationReceived = (notification: IPushNotification & EMSPushNotification): void => {
// ...
};
useEffect(() => {
PushNotification.configure<EMSPushNotification>({
// ...
onNotification: notificationReceived,
// ...
});
}, []);
return null;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment