Last active
October 11, 2019 18:43
-
-
Save tmikeschu/e6a6cb268cdc424247a9fc86dd34906c to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// 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