TypeScript: I have a method in the DataProvider class with a method getTableData:
public static getTableData(ty
maybe this would help:
export abstract class BaseEntity {
public static from(c: new() => T, data: any): T {
return Object.assign(new c(), data)
}
public static first(c: new() => T, data) {
if (data.rows.length > 0) {
let item = data.rows.item(0);
return BaseEntity.from(c, item);
}
return null;
}
}
This class can be extended by others so you could call methods on the base class or on its subclasses.
For instance:
return Product.first(Product, data);
Or:
return BaseEntity.first(Product, data);
See how from() method is called from inside first()