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


TypeScript AppState.AppState類代碼示例

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


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

示例1: setTagName

 setTagName(tagPath: Array<any>, newName: string) {
   let namePath = this.flattenPath([tagPath, 'name']);
   let oldName = this.state.getIn(namePath);
   // TODO: make this triggered by the name change?
   let state = this.state.updateIn(
     ['database'],
     db => db.renameTag(oldName, newName));
   this.updateByPath(namePath, _ => newName, state);
 }
開發者ID:gaborfeher,項目名稱:grantmaster,代碼行數:9,代碼來源:StateService.ts

示例2: addNewItem

  addNewItem(table: GenericTable<any>, targetPath: Array<any>) {
    console.log('adding ', table.newItem.toJS());
    let validationErrors = table.newItem.validate();
    if (validationErrors.length > 0) {
      console.log('validation error ', validationErrors);
      window.alert('validation error ' + validationErrors);
      return;
    }

    let newItemPath = table.myPath.concat(['newItem']);
    targetPath = this.flattenPath(targetPath);

    let newItem = table.newItem.set(
        'id', this.state.database.nextUniqueId);
    console.log('new id= ', newItem.id);
    let state = this.state
      .setIn(
          newItemPath,
          table.newItemTemplate)
      .updateIn(
          ['database'],
          d => d.incrementNextUniqueId());
    this.updateByPath<any>(  // any should be Immutable.List
      targetPath,
      list => list.push(newItem),
      state);
  }
開發者ID:gaborfeher,項目名稱:grantmaster,代碼行數:27,代碼來源:StateService.ts

示例3: addProject

 addProject(project: Project) {
   this.updateState(
     this.state.updateIn(['database', 'projects'], projects => projects.push(project)));
 }
開發者ID:gaborfeher,項目名稱:grantmaster,代碼行數:4,代碼來源:StateService.ts

示例4: getIn

 getIn(path: Array<any>): any {
   return this.state.getIn(this.flattenPath(path));
 }
開發者ID:gaborfeher,項目名稱:grantmaster,代碼行數:3,代碼來源:StateService.ts

示例5: setProjectName

 setProjectName(projectPath: Array<any>, name: string) {
   this.updateState(
     this.state.setIn(
       this.flattenPath([projectPath, 'name']),
       name));
 }
開發者ID:gaborfeher,項目名稱:grantmaster,代碼行數:6,代碼來源:StateService.ts


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