phelia
phelia copied to clipboard
message external callbacks
First of all, thank you for awesome project!
However I can't see way to trigger external methods. We have server with many features, and what to add slack integration to trigger some methods of our services. Phelia runs over our nestjs app.
For example inside our service we have method setNotificationViewed(itemId:string, viewed:boolean) and we send user message with button. So we want somehow hide button after use and trigger external method. It would be nice to have something like this:
const key = this.phelia.postMessage(TestMsg, '@user', {
itemId,
buttonPressed: ()=>this.setNotificationViewed(itemId, true),
})
and in TestMsg:
const handleBtnClick = () => {
props.buttonPressed()
setButtonHidden(true)
}
but for now props seems to be stringified and doesn't accept functions. We can't modify this behaviour because JSON.stringify is not part of storage but part of Phelia, while it is used in each Storage.set.