angular - kendo-scheduler 的 base-edit.service 中的 source 做了什么?
问题描述
我正在尝试了解 kendo-ui 中的编辑服务示例(链接),以了解调度程序的角度(处于测试阶段)。EditService 类扩展了 BaseEditService。
我的代码中 editService 的 read() 函数如下所示:
public read(): void {
if (this.data.length) {
this.source.next(this.data);
return;
}
this.fetch().subscribe(data => {
this.data = data.map(item => this.readEvent(item));
this.source.next(this.data);
},null, null
);
}
我不明白this.source.next(this.data)做了什么。
根据base-edit.service.d.ts:
/**
* The source subject for the `events` observable.
*/
protected source: BehaviorSubject<TEvent[]>;
深入研究 BehaviorSubject(来自 RxJS)会显示一条评论
* A variant of Subject that requires an initial value and emits its current
* value whenever it is subscribed to.
我开始认为 this.data 需要输入到 this.source.next() 中,原因是它没有在一行中完成,如下所示
this.source.next(data.map(item => this.readEvent(item)));
是因为当数据已经存在时,它需要 if 语句。
解决方案
推荐阅读
- plot - 如何在 Tableau 中为区号添加筛选器时创建计算以查看差异?
- javascript - 使用 JavaScript 向可悬停元素添加类
- java - 如何在@RestResource 中将“路径”设为空以使端点仅作为 /search{?name}
- java - 如何在此代码中防止或处理 java.lang.ArrayIndexOutOfBoundsException?
- python - 如何在 Python 中对列表中的元素进行分组?
- java - 如何在参数内没有Node的情况下编写depth()方法?
- jquery - 如何仅使水平滚动条从右向左滚动,而不使同一div的垂直滚动条
- php - 使用PHP获取各种ID的SQL数据
- docker - 在 docker-compose 中开发。让容器识别代码更改
- reactjs - Socket.io 客户端不适用于 React Native