Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support ASYNC extraAction functions #101

Open
Maikel-Nait opened this issue Nov 23, 2021 · 0 comments
Open

support ASYNC extraAction functions #101

Maikel-Nait opened this issue Nov 23, 2021 · 0 comments

Comments

@Maikel-Nait
Copy link

Describe the bug:

Custom extraActions works great, as long as they are synchronous functions. Modifying schema or formData objects inside these synchtronous functions effectively updates the schema / formData fields.

The problem comes when trying to use async functions when executing extraActions.
Although async functions can be executed successfully, updating schema or formData objects do not have any effect.

For example, I have an async extraAction that performs an AJAX call and, based on the response, updates the formData object.
Even though the formData object is updated with the AJAX response, no changes are rendered on the form.

I believe the problem comes from the fact rulesRunner.doRunRules calls all the extraAction events in a synchronous way

events.forEach((event) => execute(event, schemaCopy, uiSchemaCopy, formDataCopy, extraActions) );

If any of the "execute" calls is actually an async function , the xxxCopy parameters are updated when doRunRules have actually ended, and the update takes no effect.

Not sure if I'm exactly right about the root cause, but in any case, async extraActions do not work.
Is there any workaround for this, or an easy fix on the library that would allow this scenario to work ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant