Skip to content

support ASYNC extraAction functions #101

@Maikel-Nait

Description

@Maikel-Nait

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 ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions