这是我的服务类的外观,可以帮助我创建新的主题并对其进行订阅,每次需要在两个实例中更新数据更改时。
@Injectable()
export class Managementservice {
private readonly Client_Management = "management";
private cachedManagement = new CachedRestCallResponse();
Constructor(){}
getManagement(order?: ORDER)Observable<Management> {
const orderCachedRef = order?: ORDER:'UNKNOWN;
const var = order ? { order : order } : {};
if (!this.cachedManagement[orderCachedRef]) {
this.cachedManagement[orderCachedRef] = this.get<Management>
(this.Client_Management, var).publishReplay(1).refCount();
}
return this.cachedManagement[orderCachedRef];
}
postManagement(management: Management, Order?: ORDER):
Observable<Management> {
const orderCachedRef = order?: ORDER:'UNKNOWN;
this.cachedManagement[orderCachedRef] = null;
const var = ( id: ID);
if (order) {
var['order'] = order;
}
return this.post<Management>(this.Client_Management, management, var);
}
}