Using custom components in an app
I will give an example so its easier to undestand. Lets say i want a component to look up adresses. By default the component is in its search state, then by writing into a searchfield it will set an output and a background script will run with those perameters, eg {"action": "search_query", "query": "abc"}. the script will then do some things and will return something like {"action": "search_suggestion", "suggestions": [x, y, z]}, this will then trigger a recalculation of the component and it will see those perameters and rerender itself. This will go on in a "loop", back and forth where everything is stateless.
I am wondering if there is an easier approach? Do people use APIs? In that case how, and can you use background scripts in an app for that?
Any help is appreciated.