本文整理汇总了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);
}
示例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);
}
示例3: addProject
addProject(project: Project) {
this.updateState(
this.state.updateIn(['database', 'projects'], projects => projects.push(project)));
}
示例4: getIn
getIn(path: Array<any>): any {
return this.state.getIn(this.flattenPath(path));
}
示例5: setProjectName
setProjectName(projectPath: Array<any>, name: string) {
this.updateState(
this.state.setIn(
this.flattenPath([projectPath, 'name']),
name));
}