本文整理匯總了TypeScript中meteor/check.Match.Optional方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Match.Optional方法的具體用法?TypeScript Match.Optional怎麽用?TypeScript Match.Optional使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類meteor/check.Match
的用法示例。
在下文中一共展示了Match.Optional方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: function
addChat: function (roomId: string, message: { text: string, timestamp: Date, tags: string }) {
check(roomId, String);
check(message, {
text: String,
timestamp: Date,
// Optional, but if present must be an array of strings.
tags: Match.Optional('Test String')
});
// ... do something with the message ...
}
示例2: constructor
constructor(
hCurObserver: Meteor.LiveQueryHandle,
hAutoNotify?: Tracker.Computation) {
check(hAutoNotify, Match.Optional(Tracker.Computation));
check(hCurObserver, Match.Where(function(observer) {
return !!observer.stop;
}));
this._hAutoNotify = hAutoNotify;
this._hCurObserver = hCurObserver;
}
示例3: check
check(roomId, String);
check(message, {
text: String,
timestamp: Date,
// Optional, but if present must be an array of strings.
tags: Match.Optional('Test String')
});
// ... do something with the message ...
}
});
/**
* From Match patterns section
*/
var pat = { name: Match.Optional('test') };
check({ name: "something" }, pat) // OK
check({}, pat) // OK
check({ name: undefined }, pat) // Throws an exception
// Outside an object
check(undefined, Match.Optional('test')); // OK
/**
* From Deps, Tracker.autorun section
*/
Tracker.autorun(function () {
var oldest = Monkeys.findOne('age = 20');
if (oldest)
Session.set("oldest", oldest.name);