本文整理匯總了TypeScript中hubot.Brain類的典型用法代碼示例。如果您正苦於以下問題:TypeScript Brain類的具體用法?TypeScript Brain怎麽用?TypeScript Brain使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Brain類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1:
const loadState = (brain: Brain): SniperState => {
const state = brain.get<SniperState>('sniperino');
if (state) {
return state;
}
const newState = { games: {}, stats: {} };
brain.set('sniperino', newState);
return newState;
};
示例2:
import * as Hubot from "hubot";
const brain = new Hubot.Brain();
brain; // $ExpectType Brain
brain.userForName('someone'); // $ExpectType any
const robot = new Hubot.Robot(
'src/adapters',
'slack',
false,
'hubot',
);
robot; // $ExpectType Robot
robot.hear(/hello/, () => null); // $ExpectType void
示例3:
import * as Hubot from "hubot";
const robot = new Hubot.Robot<{}>(
'src/adapters',
'slack',
false,
'hubot',
);
robot; // $ExpectType Robot<{}>
robot.adapter; // $ExpectType {}
robot.hear(/hello/, () => null); // $ExpectType void
robot.on('test', () => null); // $ExpectType Robot<{}>
robot.emit('test', 'arg'); // $ExpectType boolean
const brain = new Hubot.Brain(robot);
brain; // $ExpectType Brain<{}>
brain.userForName('someone'); // $ExpectType User
brain.get('test'); // $ExpectType any
brain.set('test', 'test'); // $ExpectType Brain<{}>