本文整理匯總了TypeScript中meteor/meteor.Meteor.startup方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Meteor.startup方法的具體用法?TypeScript Meteor.startup怎麽用?TypeScript Meteor.startup使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類meteor/meteor.Meteor
的用法示例。
在下文中一共展示了Meteor.startup方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: function
return function(cls) {
// get annotations
let annotations = Reflect.getMetadata('annotations', cls) || [];
// set selector if undefined
args.selector = args.selector || 'ion-app';
// if no template was provided, default so it has a root <ion-nav>
if (!args.templateUrl && !args.template) {
args.template = '<ion-nav></ion-nav>';
}
// create @Component
annotations.push(new Component(args));
// redefine with added annotations
Reflect.defineMetadata('annotations', annotations, cls);
// wait for meteor platform
Meteor.startup(function() {
// define array of bootstrap providers
let providers = ionicProviders(args).concat(args.providers || [], METEOR_PROVIDERS);
// auto add Ionic directives
let directives = args.directives ? args.directives.concat(IONIC_DIRECTIVES) : IONIC_DIRECTIVES;
// automatically provide all of Ionic's directives to every component
providers.push(provide(PLATFORM_DIRECTIVES, { useValue: [directives], multi: true }));
if (args.prodMode) {
enableProdMode();
}
bootstrap(cls, providers).then( appRef => {
postBootstrap(appRef, args.prodMode);
});
return cls;
});
return cls;
}
示例2: loadChannels
export function loadChannels(){
Meteor.startup(function(){
for(let channel of channels){
if(Channels.find().count()<1){
Channels.insert(channel);
}
}
});
}
示例3: Promise
import { Mongo } from 'meteor/mongo';
import { config } from './config'
var Mysql = Npm.require('mysql');
var Client = Npm.require('ftp');
var genome, exp;
var pool = Mysql.createPool(config);
class main{
public temp: Mongo.Cursor<Object>
}
Meteor.startup(() => {});
Meteor.methods({
// Main insertion function
'insert':function(data) {
console.log('Ready to transfer data');
return new Promise((resolve, reject)=> {
pool.getConnection((err, connection) => {
console.log('ok');
var uid_list=[];
data.forEach(function(listitem,index){
console.log('ITERATION _'+index);
connection.query(
//'UPDATE labdata SET ? WHERE id IN (3804,3803)',{notes:[data[index].notes]},(err,res)=>{
'INSERT INTO labdata SET ?', data[index] , (err, res)=> {
console.log(data[index]);
示例4: enableProdMode
import './imports/polyfills';
import { Meteor } from 'meteor/meteor';
import { enableProdMode } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './imports/app/app.module';
Meteor.startup(() => {
if (Meteor.isProduction) {
enableProdMode();
}
platformBrowserDynamic().bootstrapModule(AppModule);
});
示例5: importPictureFromUrl
Meteor.startup(() => {
if (Meteor.settings) {
Object.assign(Accounts._options, Meteor.settings['accounts-phone']);
SMS.twilio = Meteor.settings['twilio'];
}
// Configuring oAuth services
const services = Meteor.settings.private.oAuth;
if (services) {
for (let service in services) {
ServiceConfiguration.configurations.upsert({service: service}, {
$set: services[service]
});
}
}
if (Users.collection.find().count() > 0) {
return;
}
let picture = importPictureFromUrl({
name: 'man1.jpg',
url: 'https://randomuser.me/api/portraits/men/1.jpg'
});
Accounts.createUserWithPhone({
phone: '+972540000001',
profile: {
name: 'Ethan Gonzalez',
pictureId: picture._id
}
});
picture = importPictureFromUrl({
name: 'lego1.jpg',
url: 'https://randomuser.me/api/portraits/lego/1.jpg'
});
Accounts.createUserWithPhone({
phone: '+972540000002',
profile: {
name: 'Bryan Wallace',
pictureId: picture._id
}
});
picture = importPictureFromUrl({
name: 'woman1.jpg',
url: 'https://randomuser.me/api/portraits/women/1.jpg'
});
Accounts.createUserWithPhone({
phone: '+972540000003',
profile: {
name: 'Avery Stewart',
pictureId: picture._id
}
});
picture = importPictureFromUrl({
name: 'woman2.jpg',
url: 'https://randomuser.me/api/portraits/women/2.jpg'
});
Accounts.createUserWithPhone({
phone: '+972540000004',
profile: {
name: 'Katie Peterson',
pictureId: picture._id
}
});
picture = importPictureFromUrl({
name: 'man2.jpg',
url: 'https://randomuser.me/api/portraits/men/2.jpg'
});
Accounts.createUserWithPhone({
phone: '+972540000005',
profile: {
name: 'Ray Edwards',
pictureId: picture._id
}
});
});
示例6: loadTestData
'use strict';
import {Meteor} from 'meteor/meteor';
import {loadTestData} from './test_data';
import './pubs';
Meteor.startup(function() {
loadTestData();
});
示例7: function
name: string;
}
var Monkeys = new Mongo.Collection<MonkeyDAO>('monkeys');
//var x = new Mongo.Collection<xDAO>('x');
//var y = new Mongo.Collection<yDAO>('y');
/********************************** End setup for tests *********************************/
/**
* From Core, Meteor.startup section
* Tests Meteor.isServer, Meteor.startup, Collection.insert(), Collection.find()
*/
if (Meteor.isServer) {
Meteor.startup(function () {
if (Rooms.find().count() === 0) {
Rooms.insert({ name: "Initial room" });
}
});
}
/**
* From Publish and Subscribe, Meteor.publish section
**/
Meteor.publish("rooms", function () {
return Rooms.find({}, { fields: { secretInfo: 0 } });
});
Meteor.publish("adminSecretInfo", function () {
return Rooms.find({ admin: this.userId }, { fields: { secretInfo: 1 } });
});
示例8:
import { Meteor } from 'meteor/meteor';
import { Quotes } from '../collections/quotes';
import quotesData from './quotes.data';
// Init Data if (Quotes) Collection is empty
Meteor.startup(() => {
if (Quotes.find().count() == 0)
quotesData.forEach(quote => Quotes.insert(quote) );
});
示例9: throwUnlessAuthed
return true;
}
export function throwUnlessAuthed(self, logData) {
if (!isAuthed(self)) {
Logger.error(self, {type: 'not-authorized', requested: logData});
throw new Meteor.Error("not-authorized");
}
}
const denyAll = {
insert() { return true; },
update() { return true; },
remove() { return true; },
};
export function denyAllCollectionMethods(collection) {
collection.deny(denyAll);
}
Meteor.startup(function () {
MeteorMethodsUnsafe({
isAuthed: function() {
return isAuthed(this);
},
getMyEmail: function() {
return getEmail(this);
}
});
});
示例10: moment
Meteor.startup(() => {
if (Chats.find({}).cursor.count() === 0) {
let chatId;
chatId = Chats.collection.insert({
title: 'Ethan Gonzalez',
picture: 'https://randomuser.me/api/portraits/thumb/men/1.jpg'
});
Messages.collection.insert({
chatId: chatId,
content: 'You on your way?',
createdAt: moment().subtract(1, 'hours').toDate(),
type: MessageType.TEXT
});
chatId = Chats.collection.insert({
title: 'Bryan Wallace',
picture: 'https://randomuser.me/api/portraits/thumb/lego/1.jpg'
});
Messages.collection.insert({
chatId: chatId,
content: 'Hey, it\'s me',
createdAt: moment().subtract(2, 'hours').toDate(),
type: MessageType.TEXT
});
chatId = Chats.collection.insert({
title: 'Avery Stewart',
picture: 'https://randomuser.me/api/portraits/thumb/women/1.jpg'
});
Messages.collection.insert({
chatId: chatId,
content: 'I should buy a boat',
createdAt: moment().subtract(1, 'days').toDate(),
type: MessageType.TEXT
});
chatId = Chats.collection.insert({
title: 'Katie Peterson',
picture: 'https://randomuser.me/api/portraits/thumb/women/2.jpg'
});
Messages.collection.insert({
chatId: chatId,
content: 'Look at my mukluks!',
createdAt: moment().subtract(4, 'days').toDate(),
type: MessageType.TEXT
});
chatId = Chats.collection.insert({
title: 'Ray Edwards',
picture: 'https://randomuser.me/api/portraits/thumb/men/2.jpg'
});
Messages.collection.insert({
chatId: chatId,
content: 'This is wicked good ice cream.',
createdAt: moment().subtract(2, 'weeks').toDate(),
type: MessageType.TEXT
});
}
});