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

Using .process.subscribe() messes up the display. #276

Closed
yaru22 opened this issue Aug 26, 2015 · 3 comments · May be fixed by saurabharch/proxy-router#1 or rangle/slush-ngnext-component#11
Closed
Labels

Comments

@yaru22
Copy link

yaru22 commented Aug 26, 2015

If I use the following code, questions are displayed properly (see the screenshot below):

var _ = require('lodash');
var inquirer = require('inquirer');

inquirer.prompt([
  {
    type: 'list',
    name: 'questionA',
    message: 'Question A?',
    choices: ['Yes', 'No'],
  },
  {
    type: 'list',
    name: 'questionB',
    message: 'Question B?',
    choices: ['Yes', 'No'],
  },
])

screen shot 2015-08-25 at 8 39 24 pm

However, if I use .process.subscribe(), it messes up the display a bit.

var _ = require('lodash');
var inquirer = require('inquirer');

inquirer.prompt([
  {
    type: 'list',
    name: 'questionA',
    message: 'Question A?',
    choices: ['Yes', 'No'],
  },
  {
    type: 'list',
    name: 'questionB',
    message: 'Question B?',
    choices: ['Yes', 'No'],
  },
])
.process.subscribe(_.noop, _.noop, function () {
  console.log('Completed.');
});

screen shot 2015-08-25 at 8 40 56 pm

I'm using version 0.9.0 with Node 0.12.7 on Mac.

Thanks.

@rtsao
Copy link

rtsao commented Sep 8, 2015

I'm getting the same issue with duplicate output

Possibly related: #209

@SBoudrias SBoudrias added the bug label Sep 14, 2015
@SBoudrias
Copy link
Owner

Ok, I could reproduce this bug. Not sure what on rx.js side is breaking that flow. I'll investigate.

@SBoudrias
Copy link
Owner

Well, the bug is pretty simple to find.

Basically when you add an extra listeners, each items in the array get processed again (this here is going to get called twice https://github.com/SBoudrias/Inquirer.js/blob/master/lib/ui/prompt.js#L61).

Gonna have to read RX documentation to see how to not rerun the whole process for each listeners... Pr welcomed.

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