Coder Social home page Coder Social logo

Comments (4)

markostanimirovic avatar markostanimirovic commented on June 6, 2024 1

Hi @ValentinBossi,

Feel free to create a PR to fix the example. There are two options:

  1. Fix that you mentioned.
  2. Or:
      pipe(
        debounceTime(300),
        distinctUntilChanged(),
        tap(() => patchState(store, { isLoading: true })),
        switchMap((query) => {
          return booksService.getByQuery(query).pipe(
            tapResponse({
              next: (books) => patchState(store, { books, isLoading: false }),
              error: (err) => {
                patchState(store, { isLoading: false });
                console.error(err);
              },
            })
          );
        }),
      )

from platform.

timdeschryver avatar timdeschryver commented on June 6, 2024

Hi, I don't know if I understand the question.

It does not switch back to true as expected (it looks like some klicks are just swallowed. only waiting for a couple of seconds helps, until everything works again)

This is the behavior of debounceTime: "The timeout duration in milliseconds (or the time unit determined internally by the optional scheduler) for the window of time required to wait for emission silence before emitting the most recent source value."

Moving the logic in the tap to switchMap should not affect this behavior.

from platform.

ValentinBossi avatar ValentinBossi commented on June 6, 2024

Hi @timdeschryver thanks for checking this issue!
i have made a gif which shows it better than my words:
watch_signal

in case A (using patchState in tap) im able to hold isLoading=false (while typing > 300ms). that should not be possible if im correct (at least i was not able to do it in case B). in case B (using patchState in switchMap) what is possible, if im correct, is to hold isLoading=true if im always in the time constraint of which is given by debounceTime(300)&delay(2000).

maybe im doing it not really the same way in both cases and everthing is ok or i misunderstand something.
anyway thanks for checking!

from platform.

ValentinBossi avatar ValentinBossi commented on June 6, 2024

just for the record:
finalize (andcomplete) should not be used in this case, cause switchMap calls unsubscribe on the "service" which triggers finalize (and complete) in tapResponse. this sets loading to false which is not the desired behaviour.

from platform.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.