Post 9yFC3llvP9bPHpp4a0 by Feuerfuchs@fedi.vulpes.one
(DIR) More posts by Feuerfuchs@fedi.vulpes.one
(DIR) Post #9yFC3iKADuc6aroMOO by BadAtNames@mastodon.technology
2020-08-18T09:54:12Z
0 likes, 0 repeats
How do I use postMessage in a type safe way?
(DIR) Post #9yFC3jbZSg8EZ8xmAC by BadAtNames@mastodon.technology
2020-08-18T10:05:17Z
0 likes, 0 repeats
Right now my approach uses generics to define messages as interfaces which describe functions that can listen to a given messageThis works well but is complicated and I was wondering if there was a better method I could use instead
(DIR) Post #9yFC3llvP9bPHpp4a0 by Feuerfuchs@fedi.vulpes.one
2020-08-18T10:34:19.973376Z
0 likes, 0 repeats
@BadAtNames Some context would be helpful. :blobfoxlaughsweat: Like, what's postMessage? What is your project even about? Is the code available somewhere so I can view it?
(DIR) Post #9yFCmg5LOXL8gGJtMe by BadAtNames@mastodon.technology
2020-08-18T10:41:12Z
1 likes, 0 repeats
@Feuerfuchs don't have my laptop with me but it's a webextension, using the https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/runtime/sendMessage api which is similiar to the window.postmessage api, except it's connectionless and allows you to return promises. I was asking for postmessage since I assumed it was more commonly used and I could use whatever approach worked for postmessage here too