1 min readNov 8, 2019
Both options work the same way. It is usually advisable to return a subject “as an observable” though so that the client-code can’t use the subject to emit data.
As a result, I would recommend to always use asObservable()
Both options work the same way. It is usually advisable to return a subject “as an observable” though so that the client-code can’t use the subject to emit data.
As a result, I would recommend to always use asObservable()
Google Developer Expert in Angular, Consultant and Trainer at http://www.angulartraining.com