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


TypeScript object.set函數代碼示例

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


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

示例1: function

  return function() {
    let currentValue = get(obj, prop);

    if (isPresent(values)) {
      let currentIdx = values.indexOf(currentValue);
      let nextIdx = nextIndex(get(values, 'length'), currentIdx);

      return set(obj, prop, values[nextIdx]);
    }

    return set(obj, prop, !currentValue);
  };
開發者ID:NullVoxPopuli,項目名稱:emberclear,代碼行數:12,代碼來源:toggle.ts

示例2: transitionTo

  /*
    @method transitionTo
    @private
    @param {String} name
  */
  transitionTo(name) {
    // POSSIBLE TODO: Remove this code and replace with
    // always having direct reference to state objects

    let pivotName = extractPivotName(name);
    let state = this.currentState;
    let transitionMapId = `${state.stateName}->${name}`;

    do {
      if (state.exit) {
        state.exit(this);
      }
      state = state.parentState;
    } while (!state[pivotName]);

    let setups;
    let enters;
    let i;
    let l;
    let map = TransitionChainMap[transitionMapId];

    if (map) {
      setups = map.setups;
      enters = map.enters;
      state = map.state;
    } else {
      setups = [];
      enters = [];

      let path = splitOnDot(name);

      for (i = 0, l = path.length; i < l; i++) {
        state = state[path[i]];

        if (state.enter) {
          enters.push(state);
        }
        if (state.setup) {
          setups.push(state);
        }
      }

      TransitionChainMap[transitionMapId] = { setups, enters, state };
    }

    for (i = 0, l = enters.length; i < l; i++) {
      enters[i].enter(this);
    }

    this.currentState = state;
    if (this.hasRecord) {
      set(this._record, 'currentState', state);
    }

    for (i = 0, l = setups.length; i < l; i++) {
      setups[i].setup(this);
    }

    this.updateRecordArrays();
  }
開發者ID:emberjs,項目名稱:data,代碼行數:65,代碼來源:internal-model.ts

示例3: typeahead

  /**
   * Before we call onTypeahead, we cancel the last search task if available
   * and save the new one
   * @param text user typed text
   */
  typeahead(text: string): PromiseOrTask<Array<string>> {
    this.cancelTypeaheadTask();

    const typeaheadTask = this.onTypeahead(text);
    set(this, 'typeaheadTask', typeaheadTask);
    return typeaheadTask;
  }
開發者ID:alyiwang,項目名稱:WhereHows,代碼行數:12,代碼來源:search-box.ts

示例4: get

const databaseInstance = (adapter: RealtimeDatabaseAdapter) => {
    let database = get(adapter, 'database');
    if (!database) {
        const app = get(adapter, 'firebaseApp');
        const databaseURL = get(adapter, 'databaseURL');
        database = app.database(databaseURL);
        set(adapter, 'database', database);
    }
    return database;
}
開發者ID:firebase,項目名稱:emberfire,代碼行數:10,代碼來源:realtime-database.ts

示例5: onSubmit

  /**
   * When user intents to perform a search
   */
  onSubmit(): void {
    if (this.inputText && this.inputText.trim().length > 0) {
      // this will prevent search text from jitter,
      // since inputText may differ from text, PWS will try to restore
      // text since there was not a selection, but we will set text from the route
      // at a later point. That will cause the search box to show  for example:
      // => car // press enter
      // => somethingelse //after onSubmit
      // => car // route sets car

      set(this, 'text', this.inputText);
      this.onSearch(this.inputText);
      if (this.powerSelectApi) {
        this.powerSelectApi.actions.close();
      }
    }
  }
開發者ID:alyiwang,項目名稱:WhereHows,代碼行數:20,代碼來源:search-box.ts

示例6: get

const getFirestore = (adapter: FirestoreAdapter) => {
    let cachedFirestoreInstance = get(adapter, 'firestore');
    if (!cachedFirestoreInstance) {
        const app = get(adapter, 'firebaseApp');
        cachedFirestoreInstance = app.firestore().then(firestore => {
            const settings = get(adapter, 'settings');
            firestore.settings(settings);
            const enablePersistence = get(adapter, 'enablePersistence');
            const fastboot = getOwner(adapter).lookup('service:fastboot');
            if (enablePersistence && (fastboot == null || !fastboot.isFastBoot)) {
                const persistenceSettings = get(adapter, 'persistenceSettings');
                firestore.enablePersistence(persistenceSettings).catch(console.warn);
            }
            return firestore;
        });
        set(adapter, 'firestore', cachedFirestoreInstance);
    }
    return cachedFirestoreInstance;
};
開發者ID:firebase,項目名稱:emberfire,代碼行數:19,代碼來源:firestore.ts

示例7: set

const confirmOwner = (owner: IOwner, confirmedBy: string): IOwner['confirmedBy'] =>
  set(owner, 'confirmedBy', confirmedBy || null);
開發者ID:alyiwang,項目名稱:WhereHows,代碼行數:2,代碼來源:owner.ts

示例8: finishedReloading

 finishedReloading() {
   this.isReloading = false;
   if (this.hasRecord) {
     set(this._record, 'isReloading', false);
   }
 }
開發者ID:emberjs,項目名稱:data,代碼行數:6,代碼來源:internal-model.ts

示例9: startedReloading

 startedReloading() {
   this.isReloading = true;
   if (this.hasRecord) {
     set(this._record, 'isReloading', true);
   }
 }
開發者ID:emberjs,項目名稱:data,代碼行數:6,代碼來源:internal-model.ts

示例10: run

 let ret = run(function() {
   return set(context, key, value);
 });
開發者ID:switchfly,項目名稱:ember-test-helpers,代碼行數:3,代碼來源:setup-context.ts


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