0

I have a search form bound to a handful of fields, each field is part of a MobX store. There is then a search result component, reacting to changes triggering database searches.

update searchfields -> mobx store -> observable -> search result -> rest -> DB

Now the thing is, when the form is set up, e.g. when opening the search screen, this triggers an update for each field and thus the search result component picks this up and triggers as many rest calls as there are fields.

Is there any way to throttle on an observable? I'm thinking if I can throttle to make the observable trigger in x MS after a change, grouping changes into a single trigger. that would be pretty neat.

Roger Johansson
  • 20,991
  • 14
  • 87
  • 174
  • Have you experimented with the `delay` option to [**reaction**](https://mobx.js.org/refguide/reaction.html#options)? That might be what you need. [**autorunAsync**](https://mobx.js.org/refguide/autorun-async.html) might also be useful. – Tholle Jan 30 '18 at 18:53
  • 1
    I found debounce.js, this does exactly what I want. – Roger Johansson Jan 30 '18 at 19:01

0 Answers0