Does anyone know of a way to do promise-based messaging between the plugin and the UI? (@Gleb 🙂)
Using the globals:
parent.postMessage(...) → figma.ui.onmessage → figma.ui.postMessage(...) → window.onmessage can lead to spaghetti code… promises would be so much cleaner.
Really only the UI → Plugin direction would be fine, e.g.:
someCoolMessaging.post(type: 'get-some-data', payload: { id: 5 }).then(data => {
console.log('got some data', data)
})
.catch((error) => {
console.log('error getting data from plugin')
})
