I’m working on a Chrome extension (written primarily in Elm) where I need to make use of the (chrome.omnibox API) and the chrome.bookmarks API. I have two issues where I need guidance:
Callback in JS listener callback
In my JS-code I can listen for omnibox-changes using “chrome.omnibox.onInputChanged.addListener(callback)”. The callback parameter should be a function that looks like this: function(string text, function suggest) {…};
I would like to handle this listener callback in Elm and call the “suggest” callback with my calculated suggestions. I have currently not found a way to do this using Elm ports, because they are async. How can I handle this type of listener callback in Elm?
Callbacks in calls to Bookmarks API
I can invoke most of the functions in the bookmarks API through messages sent through ports from Elm to JS, but I cannot easily associate a request result with a bookmark API response (provided async through callbacks). How can I better integrate this with Elm? I have investigated using native/kernel modules, but that seams dirty/wrong. How to best make such an integration?