'Flutter riverpod debounce multiple dependent providers

As described in the Riverpod docs, a Riverpod provider can watch other providers to make a "processing pipeline"

I have something like this:

final prov = Provider<String>((ref){

    final w1 = ref.watch(prov1);
    final w2 = ref.watch(prov2);
    final w3 = ref.watch(prov3);
    final w4 = ref.watch(prov4);

    final complex = ExpensiveFunction(w1,w2,w3,w4);

    return complex;
}
)

prov1 to prov4 can be modified individually by various bits of UI But some UI actions cause some or all of them to change in quick succession.

How can I debounce calls to ExpensiveFunction() until none of w1..4 have changed for say 2 secs?

Many thanks



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source