Giter VIP home page Giter VIP logo

Comments (8)

thgreasi avatar thgreasi commented on July 19, 2024

I can open a PR for this, as soon as the maintainer is fine making it return a Promise only when it's available on the runtime environment. In other words, if you are using oldIE then you don't get a Promise as a result if you don't load a polyfill. That also looks backwards compatible.

from debounce.

vendethiel avatar vendethiel commented on July 19, 2024

It might be worth it as a separate package at that point, tbh.

from debounce.

daveroberts avatar daveroberts commented on July 19, 2024

The first use of the debounced function which should return a promise was returning undefined

import debounce from 'debounce'

const search = (search) => {
  return new Promise((resolve,reject)=>{
   // ...
    resolve(res.data)
  })
}

const searchDebounce = debounce(search, 250)

searchDebounce("foobar").then() // threw error, promise wasn't returned, undefined was returned

// sometime later

searchDebounce("foobar").then() // working as intended

I was able to work around the issue by switching out debounce for debouce-promise.

https://github.com/bjoerge/debounce-promise

from debounce.

vendethiel avatar vendethiel commented on July 19, 2024

That's the difference between debounce and throttle.

from debounce.

thgreasi avatar thgreasi commented on July 19, 2024

So this issue seems to be alive.
Back then I ended up publishing debounce-with-result.

from debounce.

stephenmathieson avatar stephenmathieson commented on July 19, 2024

This seems like a 100% reasonable thing to expect from this library. I'll make sure I have permissions to do so tomorrow and try to get a working version published to npm.

EDIT - PR welcome. Will merge and publish, but the change is more involved than I need to be in this library right now (only incidentally stumbled upon this issue :/)

from debounce.

kilianc avatar kilianc commented on July 19, 2024

I mean, if https://github.com/bjoerge/debounce-promise does what we want, we don't need to over-complicate this library and just add a mention in the README.md. Unless the maintainers really care about this feature!

from debounce.

sindresorhus avatar sindresorhus commented on July 19, 2024

I don't think promise supports needs to live in this package. There's debounce-promise as mentioned above and also my p-debounce package.

from debounce.

Related Issues (16)

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.