Skip to content

Instantly share code, notes, and snippets.

@jessesanders
Last active May 10, 2019 19:12
Show Gist options
  • Save jessesanders/e4466c207dcbb8ac1a2bded961e55990 to your computer and use it in GitHub Desktop.
Save jessesanders/e4466c207dcbb8ac1a2bded961e55990 to your computer and use it in GitHub Desktop.
export class UserService {
private musers$ = new BehaviorSubject<User[]>([]);
get users$(): Observable<any[]> {
return this.musers$.asObservable();
}
constructor(private httpClient: HttpClient) {}
getAll() {
this.httpClient.get<User[]>("/api/users")
.subscribe(users =>
this.musers$.next(users)
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment