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


TypeScript object.extend函數代碼示例

本文整理匯總了TypeScript中@ember/object.extend函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript extend函數的具體用法?TypeScript extend怎麽用?TypeScript extend使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了extend函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: testObserver

function testObserver() {
    EmberObject.extend({
        // TODO: enable after https://github.com/typed-ember/ember-cli-typescript/issues/290
        // valueObserver: observer('value', () => {
        //     // Executes whenever the "value" property changes
        // })
    });
}
開發者ID:AlexGalays,項目名稱:DefinitelyTyped,代碼行數:8,代碼來源:event.ts

示例2: testOnce

function testOnce() {
    EmberObject.extend({
        init() {
            run.once(this, 'processFullName');
        },

        processFullName() {
        }
    });
}
開發者ID:AlexGalays,項目名稱:DefinitelyTyped,代碼行數:10,代碼來源:ember__runloop-tests.ts

示例3: test

test('didResize and debouncedDidResize hooks are on the object', (assert: Assert) => {

  const resizeAwareObject = EObj.extend(ResizeAwareMixin);
  const subject = resizeAwareObject.create();

  assert.ok(subject.didResize, 'didResize hook is present on the subject');
  assert.equal(typeof subject.didResize, 'function', 'didResize hook is a function');
  assert.ok(subject.debouncedDidResize, 'debouncedDidResize hook is present on the subject');
  assert.equal(typeof subject.debouncedDidResize, 'function', 'debouncedDidResize hook is a function');

});
開發者ID:mike-north,項目名稱:ember-resize,代碼行數:11,代碼來源:resize-aware-test.ts

示例4: testOn

function testOn() {
    const Job = EmberObject.extend({
        logCompleted: on('completed', () => {
            console.log('Job completed!');
        })
    });

    const job = Job.create();

    sendEvent(job, 'completed'); // Logs 'Job completed!'
}
開發者ID:AlexGalays,項目名稱:DefinitelyTyped,代碼行數:11,代碼來源:event.ts

示例5: testBind

function testBind() {
    EmberObject.extend({
        init() {
            const bound = run.bind(this, this.setupEditor);
            bound();
        },

        editor: null as string | null,

        setupEditor(editor: string) {
            this.set('editor', editor);
        }
    });
}
開發者ID:AlexGalays,項目名稱:DefinitelyTyped,代碼行數:14,代碼來源:ember__runloop-tests.ts

示例6: testListener

function testListener() {
    EmberObject.extend({
        init() {
            addListener(this, 'willDestroy', this, 'willDestroyListener');
            addListener(this, 'willDestroy', this, 'willDestroyListener', true);
            addListener(this, 'willDestroy', this, this.willDestroyListener);
            addListener(this, 'willDestroy', this, this.willDestroyListener, true);
            removeListener(this, 'willDestroy', this, 'willDestroyListener');
            removeListener(this, 'willDestroy', this, this.willDestroyListener);
        },
        willDestroyListener() {
        }
    });
}
開發者ID:AlexGalays,項目名稱:DefinitelyTyped,代碼行數:14,代碼來源:event.ts

示例7: testSchedule

function testSchedule() {
    EmberObject.extend({
        init() {
            run.schedule('sync', this, () => {
                // this will be executed in the first RunLoop queue, when bindings are synced
                console.log('scheduled on sync queue');
            });

            run.schedule('actions', this, () => {
                // this will be executed in the 'actions' queue, after bindings have synced.
                console.log('scheduled on actions queue');
            });
        }
    });

    run.schedule('actions', () => {
        // Do more things
    });
}
開發者ID:AlexGalays,項目名稱:DefinitelyTyped,代碼行數:19,代碼來源:ember__runloop-tests.ts

示例8: testEvented

function testEvented() {
    const Person = EmberObject.extend(Evented, {
        greet() {
            this.trigger('greet');
        }
    });

    const person = Person.create();

    person.on('greet', () => {
        console.log('Our person has greeted');
    });

    person.on('greet', () => {
        console.log('Our person has greeted');
    }).one('greet', () => {
        console.log('Offer one-time special');
    }).off('event', {}, () => {});

    person.greet();
}
開發者ID:AlexGalays,項目名稱:DefinitelyTyped,代碼行數:21,代碼來源:event.ts

示例9: testDebounce

function testDebounce() {
    function runIt() {
    }

    const myContext = { name: 'debounce' };

    run.debounce(runIt, 150);
    run.debounce(myContext, runIt, 150);
    run.debounce(myContext, runIt, 150, true);

    EmberObject.extend({
        searchValue: 'test',
        fetchResults(value: string) {},

        actions: {
            handleTyping() {
                // the fetchResults function is passed into the component from its parent
                run.debounce(this, this.get('fetchResults'), this.get('searchValue'), 250);
            }
        }
    });
}
開發者ID:AlexGalays,項目名稱:DefinitelyTyped,代碼行數:22,代碼來源:ember__runloop-tests.ts

示例10:

import { assertType } from './lib/assert';
import EmberObject from '@ember/object';

const ExtendClass = EmberObject.extend({
    foo: 'hello'
});

class ES6Class extends EmberObject {
    bar: string;
}

const TestClass = EmberObject;

if (ExtendClass.detect(TestClass)) {
    assertType<string>(TestClass.create().foo);
}

if (ES6Class.detect(TestClass)) {
    assertType<string>(TestClass.create().bar);
}
開發者ID:AlexGalays,項目名稱:DefinitelyTyped,代碼行數:20,代碼來源:detect.ts


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