I want to use RXJS with typescript yeoman generator, according to the docs inquirer which is the engine under yeoman support RXJS
https://github.com/SBoudrias/Inquirer.js/#reactive-interface
I use the following
export default class myGenerator extends Generator {
...
async prompting() {
const prompts = new Subject<Generator.Question>();
await this.prompt(prompts);
prompts.next({
name: "appName",
message: "app name: ",
type: "input",
default: this.props!.appName,
validate(input: string) {
const appName = validateAppName(input);
return !appName[1] ? appName[0] : true;
},
});
prompts.next({
type: "list",
name: "tech",
message: "Which type",
default: "CLI",
choices: [{ name: "CLI" }, { name: "CloudApp" }],
});
prompts.complete();
}
Now while running it I got error :
Error: You must provide a `name` parameter
at InputPrompt.throwParamError (/usr/local/lib/node_modules/yo/node_modules/inquirer/lib/prompts/base.js:73:11)
at new Prompt (/usr/local/lib/node_modules/yo/node_modules/inquirer/lib/prompts/base.js:33:12)
at new InputPrompt (/usr/local/lib/node_modules/yo/node_modules/inquirer/lib/prompts/input.js:11:1)
at PromptUI.fetchAnswer (/usr/local/lib/node_modules/yo/node_modules/inquirer/lib/ui/prompt.js:85:25)
at MergeMapSubscriber._tryNext (/usr/local/lib/node_modules/yo/node_modules/rxjs/internal/operators/mergeMap.js:69:27)
at MergeMapSubscriber._next (/usr/local/lib/node_modules/yo/node_modules/rxjs/internal/operators/mergeMap.js:59:18)
at MergeMapSubscriber.Subscriber.next (/usr/local/lib/node_modules/yo/node_modules/rxjs/internal/Subscriber.js:66:18)
at MergeMapSubscriber.notifyNext (/usr/local/lib/node_modules/yo/node_modules/rxjs/internal/operators/mergeMap.js:95:26)
at InnerSubscriber._next (/usr/local/lib/node_modules/yo/node_modules/rxjs/internal/InnerSubscriber.js:28:21)
at InnerSubscriber.Subscriber.next (/usr/local/lib/node_modules/yo/node_modules/rxjs/internal/Subscriber.js:66:18)
events.js:170
throw er; // Unhandled 'error' event
Im not sure where to put the name
as all the prompts are providing the name property. , any idea ?
What I need is to create just two simple questions which will work with RXJS How I can do that ?
from Using RX with yeoman generator
No comments:
Post a Comment