teambition-sdk
teambition-sdk copied to clipboard
readme中示例代码的问题
@Component({
selector: 'task-detail',
template: `
<div> {{ task$?.name | async }} </div>
<div> {{ subtaskCount$ | async }} </div>
`
})
export default class TaskView {
@Input('taskId') taskId: string
private task$ = this.SDK.getTask(this.taskId) // this.taskId的值是undefined
.publishReplay(1)
.refCount()
private subtaskCount$ = this.task$
.distinctUntilKeyChanged('subtasks')
.map(task => ({
total: task.subtasks.length,
done: task.subtasks.filter(x => x.isDone).length
}))
}
taskId 是一个 @input
,从组件外部输入
getTask 执行时 taskId 的内容应该是 undefined,外部输入引起 taskId 的变化应该是之后的事情