Angular HTTPClient ReplaySubject example without query parameters
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { ReplaySubject } from 'rxjs';
import { MyType } from './my-type';
@Injectable()
export class MyService {
baseURL = "http://localhost:18674";
// Replay subject: New subscribers will get previous values
public nodes = new ReplaySubject<MyType>();
constructor(private http: HttpClient) {
// Currently only acquire nodes once
this.http.get<MyType>(`${this.baseURL}/api/myapi`).subscribe(value =>
this.values.next(value);
});
}
}