OurPlanscape / Planscape

Other
15 stars 9 forks source link

reworking resolvers and providers to reset state when navigating away #1746

Closed pflopez closed 2 weeks ago

pflopez commented 2 weeks ago

My initial idea of providing services on the routes, was so angular could destroy and initialize new instances each time we navigate away. That way, we don't need to remember to manually reset state, and start fresh each time we navigate a treatments route tree.

However, angular does destroy services provided on routes or modules (see https://github.com/angular/angular/issues/49062 and https://github.com/angular/angular/issues/37095) so this wont work.

The most straightforward path to be able to use angular lifecycle, is to provide all this on the parent component. The component does get destroyed when navigating away, and the provided service instances are destroyed with it.

This pr removes the resolver in favor of using the parent component to leverage that behavior.

Alternatively, we could use a resolver and dependencies on route or module, and manually reset state, but it kind of defeats the purpose.

gitguardian[bot] commented 2 weeks ago

️✅ There are no secrets present in this pull request anymore.

If these secrets were true positive and are still valid, we highly recommend you to revoke them. Once a secret has been leaked into a git repository, you should consider it compromised, even if it was deleted immediately. Find here more information about risks.


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.