本文整理汇总了TypeScript中@ember/runloop.run函数的典型用法代码示例。如果您正苦于以下问题:TypeScript run函数的具体用法?TypeScript run怎么用?TypeScript run使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了run函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: run
snapshot.docChanges().forEach(change => run(() => {
const normalizedData = firestoreNormalize(store, modelClass, change.doc);
switch(change.type) {
case 'added': {
const current = model.content.objectAt(change.newIndex);
if (current == null || current.id !== change.doc.id ) {
const doc = store.push(normalizedData) as any;
model.content.insertAt(change.newIndex, doc._internalModel);
}
break;
}
case 'modified': {
const current = model.content.objectAt(change.oldIndex);
if (current == null || current.id == change.doc.id) {
if (change.newIndex !== change.oldIndex) {
model.content.removeAt(change.oldIndex);
model.content.insertAt(change.newIndex, current)
}
}
store.push(normalizedData);
break;
}
case 'removed': {
const current = model.content.objectAt(change.oldIndex);
if (current && current.id == change.doc.id) {
model.content.removeAt(change.oldIndex);
}
break;
}
}
}))
示例2: run
const unsubscribe = auth.onIdTokenChanged(currentUser => run(() => {
unsubscribe();
if (currentUser) {
resolve({currentUser});
} else {
reject();
}
}))
示例3: findOrCreate
async findOrCreate(id: string, name: string): Promise<Channel> {
return await run(async () => {
try {
return await this.findAndSetName(id, name);
} catch (e) {
return await this.create(id, name);
}
});
}
示例4: findOrCreate
async findOrCreate(uid: string, name: string): Promise<Contact> {
return await run(async () => {
try {
// an exception thrown here is never caught
return await this.findAndSetName(uid, name);
} catch (e) {
return await this.create(uid, name);
}
});
}
示例5: startApp
export default function startApp(attrs?: any): App {
let attributes = merge({}, config.APP);
attributes.autoboot = true;
attributes = merge(attributes, attrs); // use defaults, but you can override;
return run(() => {
let application = App.create(attributes);
application.setupForTesting();
application.injectTestHelpers();
return application as App;
});
}
示例6: testRun
function testRun() {
run(() => { // $ExpectType number
// code to be executed within a RunLoop
return 123;
});
function destroyApp(application: EmberObject) {
run(application, 'destroy');
run(application, function() {
this.destroy();
});
}
}
示例7: testRun
function testRun() {
let r = run(function() {
// code to be executed within a RunLoop
return 123;
});
assertType<number>(r);
function destroyApp(application: Ember.Application) {
Ember.run(application, 'destroy');
run(application, function() {
this.destroy();
});
}
}