本文整理汇总了TypeScript中immutable/contrib/cursor.Cursor类的典型用法代码示例。如果您正苦于以下问题:TypeScript Cursor类的具体用法?TypeScript Cursor怎么用?TypeScript Cursor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Cursor类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: destroy
public destroy(todo:Cursor) {
this.history = this.history.push(this.todos);
this.todos.update(todos => todos.filter(function(candidate){
return candidate.get('id') !== todo.get('id');
}));
}
示例2: undo
public undo(){
if(this.history.size>0){
var i = this.history.size;
this.todos.update(todos=>this.history.last().deref());
this.history = this.history.pop();
}
}
示例3: addTodo
public addTodo(title: string){
this.history = this.history.push(this.todos);
this.todos.push(fromJS({
id: Utils.uuid(),
title: title,
completed: false
}));
}
示例4:
this.todos.update(todos => todos.filter(function(candidate){
return candidate.get('id') !== todo.get('id');
}));
示例5: toggleAll
//We use map and filter because React works very well with immutable data. This kind of data is also easier to use and even better than mutating the array.
public toggleAll(checked){
this.history = this.history.push(this.todos);
this.todos.update(value => value.map((todo:any) => {
return todo.set('completed', checked);
}));
}
示例6: clearCompleted
public clearCompleted(){
this.history = this.history.push(this.todos);
this.todos.update(todos => todos.filter(function(todo){
return !todo.get('completed');
}));
}