當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript check.Match類代碼示例

本文整理匯總了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;未經允許,請勿轉載。