本文整理汇总了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);