Skip to content

follow-up: slow and fast debounced methods are independent in getParticipants #11048

Closed

Description

@Antreesy

this.debounceSlowUpdateParticipants and this.debounceFastUpdateParticipants seem to have a different context, so if both are requested, both will be executed

https://www.npmjs.com/package/debounce library has clear() and flush() methods, although it either cancel both requests or none of them, depending on usage.

This potentially could save 1+ request to server, depending on conditions

Originally posted by @Antreesy in #11038 (comment)

Activity

  1. added this to the 💔 Backlog milestone on Nov 30, 2023
  2. DorraJaouad commented on Dec 1, 2023

    @DorraJaouad
    Contributor

    Or use flags ( e.g: isFetchedAlready). As fast comes after slow ( at least at the start of the call) :
    When fast debounce starts excecuting, it puts isFetchedAlready = true. Then , the previously last scheduled slow debounce has to check the flag. If it is true, then skip.

  3. nickvergessen commented on Dec 1, 2023

    @nickvergessen
    Member

    But we need to fetch in the future again. When would it be reset?

  4. DorraJaouad commented on Dec 1, 2023

    @DorraJaouad
    Contributor

    But we need to fetch in the future again. When would it be reset?

    So once the flag is checked in slow debounce and it was true, you reset to false inside that check. That slow debounce call is the last one before fast debounces. When the call ends ( thus fast debounces end), the slow debounce finds the flag already false so it works normally.

    In other terms, it uses the fact that the first fast debounce ( where the flag value is changed) marks the end of slow debounce.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions