Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

having a timeout for mobx's when?

Tags:

mobx

Is there a clean way for a mobx when() call to fire after a timeout even if the predicate hasn't been true?

I could set an observable after a setTimeout and check that in the predicate, but then I'd have more to clean up. when has an options parameter but I haven't found the documentation for it.

like image 954
Frank Schwieterman Avatar asked Apr 26 '26 00:04

Frank Schwieterman


1 Answers

Use whenWithTimeout from mobx-utils package

If you are using MobX 4.0.0 or higher you can just pass timeout directly to when as its option (3rd parameter). It has been mentioned in the changelog

like image 193
Alik Avatar answered May 04 '26 12:05

Alik



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!