本文整理匯總了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));
}