Are $scope.$emit()
and $scope.$broadcast()
synchronous or asynchronous in the literal sense?
For example, in the cases
$scope.$emit()
console.log(" I am finished sending events");
and
$scope.$broadcast()
console.log(" I am finished sending events");
If all the listeners are synchronous (have no ajax calls etc) will the logging only happen after all listeners receive their events?
A common misconception in Angular development is regarding whether observables are synchronous or asynchronous. A lot of (even experienced Angular developers) think that observables are async, but the truth is that they can be… Both synchronous and asynchronous.
Broadcast: We can pass the value from parent to child (i.e parent -> child controller.) Emit: we can pass the value from child to parent (i.e.child ->parent controller.) On: catch the event dispatched by $broadcast or $emit .
AngularJs supports async requests by default.
They are synchronous.
See also https://groups.google.com/d/msg/angular/yyH3FYAy5ZY/APANNMnolD8J
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With