mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
perf(router): Use .bind to avoid holding other closures in memory
In many JS runtimes all closures created in the same scope share a context this means that data held in one of the closures is not collected until all of the closures are collected. This change prevents the returned promise from holding a reaction that holds the entire `Router` object in memory.
This commit is contained in:
@@ -697,9 +697,8 @@ export class Router {
|
||||
|
||||
// Make sure that the error is propagated even though `processNavigations` catch
|
||||
// handler does not rethrow
|
||||
return promise.catch((e: any) => {
|
||||
return Promise.reject(e);
|
||||
});
|
||||
// perf: Use `.bind` to avoid holding the other closures in this scope while this promise is unsettled.
|
||||
return promise.catch(Promise.reject.bind(Promise));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user