0

i'm a newbie in javascript and angular, so i'm learning these. could anybody interpret below code snippet for me?

public loadDataForPage(page: number, pageSize: number, callback?: (any) => void) {
   this._http.get(this._buildDataUrl(page, pageSize))
   .subscribe((data: any) => {
      const startIndex = (page-1) * pageSize;
      this._updateData(data, startIndex);
      this._data.next(data);
      callback({data});
   });
}

i don't know this part callback?: (any) => void and callback({data});

thanks.

Vucko
  • 20,555
  • 10
  • 56
  • 107
BoBo
  • 419
  • 1
  • 4
  • 5
  • https://www.typescriptlang.org/docs/handbook/functions.html#writing-the-function-type – VLAZ Jan 23 '21 at 09:34
  • This simply means the callback?: (any) => void which you will pass to loadDataForPage method should be of type void that means the callback function should not return any value. – Aakif Jan 23 '21 at 09:38

0 Answers0