DEV Community

Discussion on: Detect swipes with reactive programming

Collapse
 
bwca profile image
Volodymyr Yepishev

Great article!

By the way, maybe the check blocks for function existence can be reduced with optional chaining?

swipeSubscription?.unsubscribe?.();
Enter fullscreen mode Exit fullscreen mode

instead of

if (typeof swipeSubscription?.unsubscribe === 'function') {
  swipeSubscription.unsubscribe();
}
Enter fullscreen mode Exit fullscreen mode

:)

Collapse
 
agoncharuks profile image
Alexander Goncharuk

Makes sense. As long as we have committed to use Typescript, no reason to not use it at its full power:)
Updated both in the article text and in the Stackblitz example.