Giter Club home page Giter Club logo

Comments (2)

JensRavens avatar JensRavens commented on July 24, 2024

If debounce is still calling your subscriber for each update, something is wrong 😀

In the test it's actually testing that some values should be discarded. It pretty much works like this:

  • First update is supplied immediately (if there are less frequent updates this is desired behaviour)
  • next update is delayed up to the interval that is specified as an argument
  • if there is another update during this timespan, the last value is discarded and the new value takes it's place (this does not reset the timer though to have consistent update calls)

Basic use case would be a textfield sending a signal on each key press, but only querying the network / database once per second. I used this in a few apps so far and it did work as intended. If it's not working for you like this it would be great to see a code snipped from you to reproduce this error.

from interstellar.

vittoriom avatar vittoriom commented on July 24, 2024

Ha, I see! I wasn't actually getting a call for each update, but I was assuming that by just looking at the tests. Maybe they could be modified so that update is called 3 times and yet 2 callbacks are fired. I think this would make the behavior more clear.

Anyway, thanks for the explanation. I think the part I missed (and didn't expect) was the first update that is fired immediately.

I'll close this since now the logic is clarified. Thanks!

from interstellar.

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.