我有一个带有cachedData
变量的类。它是一个私有变量。
此变量(cachedData)从其他类更新。我无法创建静态方法,因为无法在静态方法内执行this.cachedData
。但我也希望其他类更新此变量。我该如何实现?
class myClass implements X{
private cachedData:Array<entity>;
cacheResponseData = ( val ):void => {
this.cachedData = val;
}
clearSourceData = ():void => {
this.cachedData = null;
}
}
class OtherClass extends Y {
constructor(
dataProvider: QueryablePagedDataProvider<ReportingEntity>,
){
super(dataProvider, DataStoreMode.SINGLE_PAGE);
}
someMethod()
{
// I need to update the cachedData in this method from myClass
}
}