• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript check.Match类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中meteor/check.Match的典型用法代码示例。如果您正苦于以下问题:TypeScript Match类的具体用法?TypeScript Match怎么用?TypeScript Match使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Match类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: 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;
  }
开发者ID:GuillaumeM69,项目名称:angular2-meteor,代码行数:12,代码来源:cursor_handle.ts


示例2: 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 ...
    }
开发者ID:Jeremy-F,项目名称:DefinitelyTyped,代码行数:11,代码来源:meteor-tests.ts


示例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);
开发者ID:Jeremy-F,项目名称:DefinitelyTyped,代码行数:31,代码来源:meteor-tests.ts


示例4: initMethods

import { Meteor } from 'meteor/meteor';
import { Chats, Messages } from "../collections/whatsapp-collections";
import { check, Match } from "meteor/check";
import { Profile } from "api/models/whatsapp-models";

const nonEmptyString = Match.Where((str) => {
  check(str, String);
  return str.length > 0;
});

export function initMethods() {
  Meteor.methods({
    addChat(receiverId: string): void {
      if (!this.userId) throw new Meteor.Error('unauthorized',
        'User must be logged-in to create a new chat');

      check(receiverId, nonEmptyString);

      if (receiverId == this.userId) throw new Meteor.Error('illegal-receiver',
        'Receiver must be different than the current logged in user');

      const chatExists = !!Chats.collection.find({
        memberIds: {$all: [this.userId, receiverId]}
      }).count();

      if (chatExists) throw new Meteor.Error('chat-exists',
        'Chat already exists');

      const chat = {
        memberIds: [this.userId, receiverId]
      };
开发者ID:pro-to-tip,项目名称:pro-to-tip.github.io,代码行数:31,代码来源:methods.ts


示例5: check

import { check, Match } from 'meteor/check';

import { Chats } from './collections/chats';
import { Messages } from './collections/messages';
import { MessageType, Profile } from './models';

 const nonEmptyString = Match.Where((str) => {
   check(str, String);
   return str.length > 0;
 });

Meteor.methods({
  addChat(receiverId: string): void {
    if (!this.userId) {
      throw new Meteor.Error('unauthorized',
        'User must be logged-in to create a new chat');
    }

    check(receiverId, nonEmptyString);

    if (receiverId === this.userId) {
      throw new Meteor.Error('illegal-receiver',
        'Receiver must be different than the current logged in user');
    }

    const chatExists = !!Chats.collection.find({
      memberIds: { $all: [this.userId, receiverId] }
    }).count();

    if (chatExists) {
      throw new Meteor.Error('chat-exists',
开发者ID:ShinFDuran,项目名称:Pruebas,代码行数:31,代码来源:methods.ts


示例6: check

import {Mongo} from 'meteor/mongo';
import { Meteor } from 'meteor/meteor';
import {check} from 'meteor/check';
import { Match } from 'meteor/check'

export const Parties = new Mongo.Collection('parties');

Meteor.methods({
  'addItem'(_data) {
    
    const NonEmptyString = Match.Where(function (x) {
      check(x, String);
      return x.length > 0;
    });
    
    check(_data.title, NonEmptyString);
    check(_data.message, NonEmptyString);

    Parties.insert({
      title: _data.title,
      message: _data.message,
      created_date: new Date()
    });
  }
})


if (Meteor.isServer) {
  Meteor.publish('parties', function () {
    return Parties.find();
  });
开发者ID:aaronksaunders,项目名称:angular2-meteor-demo,代码行数:31,代码来源:parties.ts



注:本文中的meteor/check.Match类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript email.Email类代码示例发布时间:2022-05-25
下一篇:
TypeScript check.check函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap