本文整理匯總了TypeScript中minpubsub/minpubsub.publish函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript publish函數的具體用法?TypeScript publish怎麽用?TypeScript publish使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了publish函數的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: function
var testNLP = function() {
counter++;
var testString = null;
switch (counter) {
case 1 : testString = "Bill Clinton was president from 1992 to 2000. He is not the president any more."; break;
case 2 : testString = "Santa Claus is coming to town."; break;
case 3 : console.log("NLP server status: ", nlpServer.getStatus().getState());
events.publish(SERVER_AVAILABLE);
break;
case 4 : nlpServer.stop(); break;
}
// Process the string using the NLP library and print the result.
// Then fire another event to trigger the function again.
if (testString) {
nlpServer.process(testString,
function(result) {
console.log(JSON.stringify(JSON.parse(result), null, " "));
events.publish(SERVER_AVAILABLE);
});
}
}
示例2:
nlpServer.start(function() {
events.publish(SERVER_AVAILABLE);
});