本文整理匯總了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();
});
}
}