Search
Search-as-you-type with the race condition solved by construction: switchMap cancels the previous search whenever a new keyword arrives, so a slow response for an old keyword can never overwrite fresh results. This demo makes shorter keywords slower on purpose — type quickly and watch stale responses lose.
The input reads useSyncObservable (controlled inputs need synchronous updates); the results read useObservable, whose built-in deferral keeps typing responsive while results render. For the Suspense-integrated version of this comparison, see Suspense & deferred values.
Last updated on