Code Monkey home page Code Monkey logo

Comments (2)

SBoudrias avatar SBoudrias commented on June 14, 2024

Hi! Thanks for bringing that feedback

I want to batch renders to handles cases like what you outlined. I didn't have time yet to implement, but it's definitively an update the would make sense.

The code is over here if you want to give it a try. The tests should catch any regression you'd introduce (I think they're end-to-end enough to not bulk on delayed re-renders; but might need to review that too.)

from inquirer.js.

SBoudrias avatar SBoudrias commented on June 14, 2024

Implemented a naïve version of this.

So on any sync functions, the state updates will be merged (See code at 165d6d8)

But it won't work if calling multiple times setState from within an async callback (like setTimeout.) Handling those would require to have asynchronous rendering loops, and that makes everything more complicated (testing, but also just things like making sure there's no delays when typing.) Since updating multiple states from async functions are not a pattern I've encountered often creating prompts, I'm leaning on the side of simplicity for now.

(And the code demo using an object state is a good work around for custom prompt requiring multi state updates from an async callback.)

from inquirer.js.

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.