educative.io

Why do we need Pub Sub System for this problem?

When a user deviates from the optimal path from the current location to the destination, shouldn’t we get updated optimal path via findRoute API. I don’t understand why we need PubSub System here if there is user deviation from optimal path.

Hi Abhinav,

As described in the lesson, pub-sub is a system that listens to various events from a service and triggers another service(s). In case of an event where a user deviates from the optimal path, the pub-sub service triggers different connected services such as are search service, navigator, and graph building service to recalculate and suggest a new optimal path along with other information.

This asynchronous communication allows for efficient handling of dynamic changes in user journeys without needing constant manual intervention.

Thank you.

1 Like