Reactivity in frappe. Is it possible?

Can someone who understands the architecture of frappe well, say a little bit about reactivity in frappe? Basically is it possible (without adding framework like svelte) to automatically update another field by interacting in other field?

Example
Is this possible in form view?

Yes, you can achieve it using client script in Frappe.
https://frappeframework.com/docs/user/en/api/form

{fieldname} Triggered when the value of fieldname is changed

If This is what you mean, it’s just a trigger. It’s just part of reactivity

What I am asking is, can change happen as you type?

Yes, your logic is triggered in real time, but it’s debounced for a few hundred milliseconds for regular fields.

However, reactivity for fields within a child table or a child table with a parent document can be challenging.

If you’re looking for reactive streams, pipe operations, operators, it is not available. Add your favourite js lib and use it. Try using rxjs with form js api instead of completely ditching form api for a frontend framework.

1 Like

Ok, sorry my bad. It works as @Yamen_Zakhour said, after a tiny delay. I remember it not working so well for me before, but maybe that was my mistake.

However, child table field triggers the action only after you focus out of that field. Which is kinda annoying.

frappe.ui.form.on("Child table", {
    field_that_trigers(frm) {
        function the_function(){}
        the_function(frm);
        // not sure why this wont work
        frm.trigger("the_function");
    }
});

This article by @buildwithhussain was usefull to better understand it.

1 Like