I have created a Lucidchart package that contains custom UI, shapes and data connectors. I have added a button to the right panel that successfully triggers a long running task in Azure. In my current implementation, the button is pressed and the task is of course triggered async
Once the long running task is complete, is there a way for my web server to notify Lucid that the long running task is complete? What are some approaches you might recommend?
Should my extension poll a database table for the state of the task?
Alternatively, is there a way for me to register a endpoint that my web server could call and then the extension or data connector could receive that notification that the registered endpoint has been called and then run some code?
Thanks, Dan
Best answer by ablackburn
I think if they're gonna take 10 minutes the data connector route will time out, in that case it will probably be easiest to manage this mostly from your iFrame (I believe at one point you were iFraming a react/angular app, is that still true?):
Kick off the process from your extension by sending a network request to the server where the long running process runs using either `editorClient.oauthXhr` or by having your iFrame send the network request.
Have your iFrame poll the server periodically to get the current status of the job. You could alternatively establish the websocket between your iFrame and the server to get the update pushed back to you without polling.
When the iFrame detects the simulation is complete and the data is ready, fetch the data and then pass a message to the extension with the data, and have the extension draw whatever shapes you want on the canvas (we have a tutorial that does this third step here: https://developer.lucid.co/docs/data-visualization)
Great question. I think the best way to handle this would be using an asynchronous data connector action. The flow would be something like:
User does something in your extension that triggers the flow
Extension calls “editorClient.performDataAction(...)” and sets the “asynchronous” parameter of the function to true
Data connector receives the request, kicks off the long running process and waits for it to complete
Data connector receives some notification that the process has completed and uses the `action.client.update(...)` function to send a data update to the Lucid document
If you want your extension to run some code after that happens, you can use `editorClient.awaitDataImport(...)` to wait for that update to come through and then you can run whatever functionality you want.
I think polling is a valid strategy. An alternative could be to have the data connector keep a websocket open with the server running the long running job and use the websocket to send the completion back.
How long are you expecting these processes to take?
I think if they're gonna take 10 minutes the data connector route will time out, in that case it will probably be easiest to manage this mostly from your iFrame (I believe at one point you were iFraming a react/angular app, is that still true?):
Kick off the process from your extension by sending a network request to the server where the long running process runs using either `editorClient.oauthXhr` or by having your iFrame send the network request.
Have your iFrame poll the server periodically to get the current status of the job. You could alternatively establish the websocket between your iFrame and the server to get the update pushed back to you without polling.
When the iFrame detects the simulation is complete and the data is ready, fetch the data and then pass a message to the extension with the data, and have the extension draw whatever shapes you want on the canvas (we have a tutorial that does this third step here: https://developer.lucid.co/docs/data-visualization)
A Lucid account is required to interact with the Community, and your participation is subject to the
Supplemental Lucid Community Terms.
You may not participate in the Community if you are under age 18. You will be redirected to the Lucid app to log in.
A Lucid account is required to interact with the Community, and your participation is subject to the
Supplemental Lucid Community Terms.
You may not participate in the Community if you are under age 18. You will be redirected to the Lucid app to log in.