[英]Nodejs and microsoft bot framework
I am looking at the nodejs code here https://github.com/Microsoft/BotBuilder/blob/master/Node/examples/basics-waterfall/app.js 我在这里查看nodejs代码https://github.com/Microsoft/BotBuilder/blob/master/Node/examples/basics-waterfall/app.js
I am trying to understand this piece of code 我试图理解这段代码
var bot = new builder.UniversalBot(connector, [
function (session) {
...
},
function (session, results) {
...
},
function (session, results) {
...
},
function (session, results) {
...
}
]);
I understand that var bot is a function expression and takes in two parameters one is a connector and another is an array of functions. 我知道var bot是一个函数表达式,它接受两个参数,一个是连接器,另一个是函数数组。
Do these array of functions execute serially in the order they are defined ? 这些函数数组是按照它们定义的顺序串行执行的吗?
Comming from another programming background i am not familiar with this dialect. 来自另一个编程背景,我不熟悉这种方言。
How can i make this program more C# like is async await the answer ? 我如何使这个程序更像C#as async等待答案?
If async await is the answer how do i convert this to use the async/await paradigm ? 如果async await是答案,我如何将其转换为使用async / await范例?
Yes, it seems like they are executing in the order they are defined. 是的,似乎他们按照定义的顺序执行。
You are supposed to provide only the function body in that array, the actual execution happens somewhere in the bot implementation, so you'd have to look there to get a clearer picture. 你应该只提供该数组中的函数体,实际的执行发生在bot实现的某个地方,所以你必须在那里寻找更清晰的图像。
But judging from that example and common sense, it's clear that they are executed sequentially. 但从这个例子和常识来看,很明显它们是按顺序执行的。 It's a bot that answers questions in the order they are defined. 它是一个机器人,按照定义的顺序回答问题。
I'm not sure what you understand by "async" in this context, but if you want it to answer arbitrary requests, you can look at the other examples like basics-logging . 我不确定你在这个上下文中对“async”的理解是什么,但是如果你想让它回答任意请求,你可以看看其他例子,比如basics-logging 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.