Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

amplify.js pub/sub Synchronous or Asynchronous?

Tags:

javascript

Are amplify.js's pub/sub events implemented as Synchronous or Asynchronous?

http://amplifyjs.com/api/pubsub/

The documentation does mention priorities...

like image 723
David Avatar asked Jan 19 '23 01:01

David


2 Answers

Publishing is synchronous; prioritization and synchronicity aren't really related.

like image 53
Scott González Avatar answered Jan 29 '23 09:01

Scott González


It's synchronous.

The subscription callbacks are called from within the .publish() method's implementation. There is no setTimeout() code.

As far as priorities go, priority determines where to inject the callback in the callback stack. This logic is handled in .subscribe(). The .publish() method just executes the callbacks in stack order as previously determined by the .subscribe() method.

like image 28
gilly3 Avatar answered Jan 29 '23 09:01

gilly3