本文整理汇总了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;未经允许,请勿转载。 |
请发表评论