Skip to content

AB#133167 Improve performance on forms#2866

Open
Maximo-reliefapps wants to merge 1 commit into
nextfrom
AB#133167-Improve-forms-performance
Open

AB#133167 Improve performance on forms#2866
Maximo-reliefapps wants to merge 1 commit into
nextfrom
AB#133167-Improve-forms-performance

Conversation

@Maximo-reliefapps

Copy link
Copy Markdown
Contributor

Description

This PR improves form performance and prevents memory leaks by cleaning up SurveyJS event handlers, RxJS subscriptions, and active HTTP requests during the component lifecycle.

Changes

  1. choices-by-graphql.ts
  • Cancel In-Flight Requests: Triggers .next() on the existing refresh$ Subject during re-renders to cancel any pending HTTP requests before re-registering.

  • Deduplicate Event Listeners: Stored anonymous handlers as named references (_gqlLinkedChoicesHandler and _gqlValueUpdateHandler) on the question object. Used a remove-before-add pattern to prevent duplicate listeners.

  1. reference-data.ts
  • Question-Level Guard: Added a _referenceDataPropertyHandlersRegistered flag to ensure handlers register only once per question lifetime.

  • Survey-Level Cleanup: Applied the remove-before-add pattern to _referenceDataLinkedHandler and called unregisterFunctionOnPropertyValueChanged to clean up the refreshData handler.

  1. form.component.ts
  • Lifecycle Teardown (ngOnDestroy): Iterates through questions to .complete() their refresh$ subjects before disposing of the survey, cutting off active network requests.

-vMutation Guards: Added pipe(takeUntil(this.destroy$)) to the onComplete and confirmRevertDialog mutation subscriptions to prevent callbacks from running after the component is destroyed.

Useful links

Type of change

  • Improvement (refactor or addition to existing functionality)

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce.

  • General usage of the forms, checked no performance drops

Screenshots

No visual changes

Checklist:

( * == Mandatory )

  • * I have set myself as assignee of the pull request
  • * My code follows the style guidelines of this project
  • * Linting does not generate new warnings
  • * I have performed a self-review of my own code
  • * I have put the ticket for review, adding the oort-frontend team to the list of reviewers
  • * I have commented my code, particularly in hard-to-understand areas
  • * I have put JSDoc comment in all required places
  • * My changes generate no new warnings
  • * I have included screenshots describing my changes if relevant
  • * I have selected labels in the Pull Request, according to the changes with code brings
  • I have made corresponding changes to the documentation ( if required )
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

@Maximo-reliefapps Maximo-reliefapps self-assigned this Jun 4, 2026
@Maximo-reliefapps Maximo-reliefapps added enhancement New feature or request changes Changes made to existing features labels Jun 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changes Changes made to existing features enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant