Native app run nanoflow in background

1
I want to run a nanoflow in background so that once started it continues to run after specified interval like 10 seconds. User can move to any page in the app but that nanoflow should not stop. Its like getting status of a particular operation in app where app needs to communicate with some external system. So its sends a request to get status every 10 seconds until the operation is complete. I tried using app events widget. Using its timer option I could configure a nanoflow to run every x seconds. But when user leaves the page where app events widget is placed, the nanoflow is not called again.  Any suggestions how to implement above scenario in native app?
asked
2 answers
2

Perhaps this will work for you.

I added the AppEvents widget to the page layout that was used on my Native page(s) and applied the timer on this AppEvents widget.

I added a simple microflow that logged to log messages. 1 at the start and 1 at the end.

The nanoflow executes every 10 seconds and even when the page is changed.

If you are concerned that you might not be able to retrieve context information via the nanoflow for the task, I was able to retrieve data in this nanoflow.

 

answered
0

If you execute the nanoflow asynchronously, it will continue to run without being bound to the UI context/page. You can do this in a javascript action by passing in the nanoflow as an argument. Such a javascript action would look something like this:

export async function ExecuteNanoflowInBackground(nanoflow) {
	// BEGIN USER CODE
	nanoflow();
	return;
	// END USER CODE
}

And here’s what it would look like to pass the nanoflow into the JS action:

answered