Angular - Advanced Patterns
Consider this Angular service using the Observer pattern:
What happens when
import { Injectable } from '@angular/core';
import { Subject } from 'rxjs';
@Injectable({ providedIn: 'root' })
export class DataService {
private dataSubject = new Subject();
data$ = this.dataSubject.asObservable();
updateData(newData: string) {
this.dataSubject.next(newData);
}
} What happens when
updateData('Hello') is called?