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

The method passed into question is executed automatically #424

Open
hcl-z opened this issue Nov 14, 2024 · 0 comments
Open

The method passed into question is executed automatically #424

hcl-z opened this issue Nov 14, 2024 · 0 comments

Comments

@hcl-z
Copy link

hcl-z commented Nov 14, 2024

Is your feature request related to a problem?

I'd like to pass a callback-like method in question and get it and execute it when Onsubmit, but the current code will pre-execute all the methods that aren't in special functions`

  for (question of questions) {
    ({ name, type } = question);

    // evaluate type first and skip if type is a falsy value
    if (typeof type === 'function') {
      type = await type(answer, { ...answers }, question)
      question['type'] = type
    }
    if (!type) continue;

    // if property is a function, invoke it unless it's a special function
    for (let key in question) {
      if (passOn.includes(key)) continue;
      let value = question[key];
      question[key] = typeof value === 'function' ? await value(answer, { ...answers }, lastPrompt) : value;
    }

Describe the solution you'd like

Don't handle the method passed in in question, leave it intact in onSubmit

@hcl-z hcl-z changed the title Do not execute the method passed in in question The method passed into question is executed automatically Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant