WebChat 的 "store" 对象有什么作用?
What does the "store" object of the WebChat do?
对于在 Health Bot Container Sample 中找到的以下 javascript 代码片段,从 window.WebChat.createStore
创建的“store”对象,“store”对象的作用是什么? “存储”对象的用途是什么?
我正在阅读web chat api documentation,但对“商店”对象的描述和解释不清楚。
非常感谢您对此事的帮助。
const store = window.WebChat.createStore({}, function(store) { return function(next) { return function(action) {
if (action.type === 'DIRECT_LINE/CONNECT_FULFILLED') {
store.dispatch({
type: 'DIRECT_LINE/POST_ACTIVITY',
meta: {method: 'keyboard'},
payload: {
activity: {
type: "invoke",
name: "InitConversation",
locale: user.locale,
value: {
// must use for authenticated conversation.
jsonWebToken: jsonWebToken,
// Use the following activity to proactively invoke a bot scenario
/*
triggeredScenario: {
trigger: "{scenario_id}",
args: {
myVar1: "{custom_arg_1}",
myVar2: "{custom_arg_2}"
}
}
*/
}
}
}
});
}
return next(action);
}}});
商店是 Redux store. You will need to be familiar with Redux to fully understand it, but for the purposes of Web Chat you can think of it as an object that allows you to dispatch actions and use middleware. The samples in this folder 应该可以帮助您掌握它。
对于在 Health Bot Container Sample 中找到的以下 javascript 代码片段,从 window.WebChat.createStore
创建的“store”对象,“store”对象的作用是什么? “存储”对象的用途是什么?
我正在阅读web chat api documentation,但对“商店”对象的描述和解释不清楚。
非常感谢您对此事的帮助。
const store = window.WebChat.createStore({}, function(store) { return function(next) { return function(action) {
if (action.type === 'DIRECT_LINE/CONNECT_FULFILLED') {
store.dispatch({
type: 'DIRECT_LINE/POST_ACTIVITY',
meta: {method: 'keyboard'},
payload: {
activity: {
type: "invoke",
name: "InitConversation",
locale: user.locale,
value: {
// must use for authenticated conversation.
jsonWebToken: jsonWebToken,
// Use the following activity to proactively invoke a bot scenario
/*
triggeredScenario: {
trigger: "{scenario_id}",
args: {
myVar1: "{custom_arg_1}",
myVar2: "{custom_arg_2}"
}
}
*/
}
}
}
});
}
return next(action);
}}});
商店是 Redux store. You will need to be familiar with Redux to fully understand it, but for the purposes of Web Chat you can think of it as an object that allows you to dispatch actions and use middleware. The samples in this folder 应该可以帮助您掌握它。