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:
|
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.
Already done: #2301
@rfontanarosa FYI
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
Assigning this task to myself to come up with a plan to improve maintainability across the codebase.
Already done: #2301
@rfontanarosa FYI