refactor(core): profiler takes null as a default instance (#59233)

Several profiler calls don't have any meaningful instance when
producing a profiling event. This commit changes the default
instance value to null to sreamline profiler invocations.

PR Close #59233
This commit is contained in:
Pawel Kozlowski 2024-12-20 17:21:27 +01:00 committed by kirjs
parent 790221b1d2
commit c4ad8fb2e7
3 changed files with 3 additions and 3 deletions

View file

@ -43,7 +43,7 @@ export class NgProfiler extends Profiler {
private _initialize(): void {
ngDebugClient().ɵsetProfiler(
(event: ɵProfilerEvent, instanceOrLView: {} | null, hookOrListener: any) =>
(event: ɵProfilerEvent, instanceOrLView: {} | null = null, hookOrListener: any) =>
this._callbacks.forEach((cb) => cb(event, instanceOrLView, hookOrListener)),
);
}

View file

@ -33,7 +33,7 @@ export const setProfiler = (profiler: Profiler | null) => {
* execution context
* @returns
*/
export const profiler: Profiler = function (event, instance, hookOrListener) {
export const profiler: Profiler = function (event, instance = null, hookOrListener) {
if (profilerCallback != null /* both `null` and `undefined` */) {
profilerCallback(event, instance, hookOrListener);
}

View file

@ -160,5 +160,5 @@ export const enum ProfilerEvent {
* Profiler function which the runtime will invoke before and after user code.
*/
export interface Profiler {
(event: ProfilerEvent, instance: {} | null, hookOrListener?: (e?: any) => any): void;
(event: ProfilerEvent, instance?: {} | null, hookOrListener?: (e?: any) => any): void;
}