Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

automatically call .start()? #74

Open
devinrhode2 opened this issue Jul 8, 2013 · 1 comment
Open

automatically call .start()? #74

devinrhode2 opened this issue Jul 8, 2013 · 1 comment

Comments

@devinrhode2
Copy link

The idea is to eliminate the need to call prompt.start().

In a closure containing prompt.start and prompt.get:
  var started = false;
in prompt.start:
     started = true;

in prompt.get:
     if (!started) prompt.start();

This could be implemented directly with extendFunction:

(function() {
  var started = false;
  extendFunction('prompt.start', function(){
    started = true;
  });
  extendFunction('prompt.get', function(){
    if (!started) prompt.start();
  });
})();
@QxQ
Copy link

QxQ commented Dec 5, 2014

Along the same alley, maybe make prompt a class?

So, the constructor of the class can call the start function
but this allows things like setting prompt.color to false to only effect one instance

example

Prompt = require('prompt');
prompt = new Prompt; // Prompt.start() is called doing the constructor, so it doesn't need to be called.
prompt.get(['stuff'], function (err, result){});

// And maybe for backward compatibility purposes, make this possible also.
Prompt.start() // This does need to be called since we're not making an instance.
Prompt.get(['stuff'], function(err, result){});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants