Ja by som chcel nastaviť rýchly jednoduchý spôsob, ako testu funkcie v Uhlovej, kde by som stačí zadať názov funkcie raz v konštruktér a testovať ich. napr.:
constructor() {
this.test(this.FucntionName) <= logs function name and output
}
Problém s týmto je, že ak by som skúsiť prejsť funkciu ako argument bez volať to, mám to. rozsah chyba. Ako môžem dostať aj názov funkcie a jej návratovú hodnotu, keď som odovzdať ju do testu() funkcia, bez toho, aby zadajte dva argumenty?
Je tu lepšia možnosť, možno, že niektorí os linux poskytovať tento?
Môj súčasný prístup funguje, ale to je neohrabaný a chcel by som odstrániť potrebu druhý argument:
export class AuthService {
constructor(
...
) {
this.test(this.FunctionName(), 'FunctionName')// I would like to remove the need to repeat the name as string
}
test(sub: any, name) {
sub.subscribe(
data => {
console.group("==========", name, "() TEST ===============")
console.log("Output Type:", typeof data)
typeof data == 'object' ? console.table(data) : console.log(data);
console.groupEnd()
}
)
}