Giter VIP home page Giter VIP logo

Comments (4)

briancavalier avatar briancavalier commented on June 13, 2024

I believe it's mostly true: never itself does consume almost no resources, and near() will tend to collapse promise chains over time.

I'd thought about detecting never and short circuiting in merge/all/settle (I think I even wrote the code for it at some point), and I still think it's a pretty cool idea. I ended up believe that real world usages of never will be few and far between, and so I didn't feel like the extra code was worth it. I could definitely be convinced that it's worthwhile, tho, if the code to do it is extremely small and simple.

from creed.

bergus avatar bergus commented on June 13, 2024

Yes, real-world usages of never seem to be rare. I wonder if anyone used it as a poor-mans cancellation, otherwise I can hardly imagine use cases.
If anything, it might have been used in the monoid instance together with concat, but that one already is short-circuited.

from creed.

briancavalier avatar briancavalier commented on June 13, 2024

I wonder if anyone used it as a poor-mans cancellation

That's an interesting question. I hadn't even considered it :) Now I'm wondering what that would look like ... any chance you've tried it?

from creed.

bergus avatar bergus commented on June 13, 2024

I mean something like

let isCancelled = false;
cancelButton.onclick = () => { isCancelled = true; … };
….then(r => {
    if (isCancelled) return never();
    …
}).then(r => {
    if (isCancelled) return never();
    …
})

from creed.

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.