-
Notifications
You must be signed in to change notification settings - Fork 100
Open
Labels
type: code healthImprovements to readability or robustness of codebaseImprovements to readability or robustness of codebase
Description
Nested calls to subscribe() in ngOnInit, mixing signals + observables, and inconsistent and/or duplicate source-of-truth, and loose separation of concerns have made many of the components hard to grok and maintain. For example:
ground-platform/web/src/app/pages/create-survey/create-survey.component.ts
Lines 155 to 195 in a860c36
| ngOnInit(): void { | |
| this.subscription.add( | |
| this.navigationService.getSurveyId$().subscribe(async surveyId => { | |
| this.surveyId = surveyId ? surveyId : NavigationService.SURVEY_ID_NEW; | |
| this.surveyService.activateSurvey(this.surveyId); | |
| await this.draftSurveyService.init(this.surveyId); | |
| this.draftSurveyService | |
| .getSurvey$() | |
| .subscribe(survey => (this.survey = survey)); | |
| }) | |
| ); | |
| this.subscription.add( | |
| combineLatest([ | |
| this.surveyService.getActiveSurvey$(), | |
| this.loiService.getLocationsOfInterest$(), | |
| ]) | |
| .pipe( | |
| filter( | |
| ([survey]) => | |
| this.surveyId === NavigationService.SURVEY_ID_NEW || | |
| survey.id === this.surveyId | |
| ) | |
| ) | |
| .subscribe(([survey, lois]) => { | |
| this.survey = survey; | |
| if (this.isSetupFinished(this.survey)) { | |
| this.navigationService.selectSurvey(this.survey.id); | |
| } | |
| this.lois = lois; | |
| if (this.createSurveyPhase === CreateSurveyPhase.LOADING) { | |
| this.createSurveyPhase = this.getSurveyPhase(survey, lois); | |
| } | |
| if (this.createSurveyPhase === CreateSurveyPhase.DEFINE_LOIS) { | |
| this.canContinue = | |
| !this.lois.isEmpty() || | |
| this.job()?.strategy === DataCollectionStrategy.MIXED; | |
| } | |
| }) | |
| ); | |
| } |
Assigning this task to myself to come up with a plan to improve maintainability across the codebase.
@rfontanarosa FYI
Metadata
Metadata
Assignees
Labels
type: code healthImprovements to readability or robustness of codebaseImprovements to readability or robustness of codebase
Type
Projects
Status
In Progress