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


TypeScript runloop.run函數代碼示例

本文整理匯總了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;
         }
     }
 }))
開發者ID:firebase,項目名稱:emberfire,代碼行數:31,代碼來源:realtime-listener.ts

示例2: run

 const unsubscribe = auth.onIdTokenChanged(currentUser => run(() => {
     unsubscribe();
     if (currentUser) {
         resolve({currentUser});
     } else {
         reject();
     }
 }))
開發者ID:firebase,項目名稱:emberfire,代碼行數:8,代碼來源:firebase.ts

示例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);
     }
   });
 }
開發者ID:NullVoxPopuli,項目名稱:emberclear,代碼行數:9,代碼來源:channel-manager.ts

示例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);
     }
   });
 }
開發者ID:NullVoxPopuli,項目名稱:emberclear,代碼行數:10,代碼來源:contact-manager.ts

示例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;
  });
}
開發者ID:salsify,項目名稱:ember-debug-logger,代碼行數:12,代碼來源:start-app.ts

示例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();
        });
    }
}
開發者ID:AlexGalays,項目名稱:DefinitelyTyped,代碼行數:13,代碼來源:ember__runloop-tests.ts

示例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();
        });
    }
}
開發者ID:AbraaoAlves,項目名稱:DefinitelyTyped,代碼行數:14,代碼來源:run.ts


注:本文中的@ember/runloop.run函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。