本文整理汇总了TypeScript中rxjs/Subject.Subject.startWith方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Subject.startWith方法的具体用法?TypeScript Subject.startWith怎么用?TypeScript Subject.startWith使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rxjs/Subject.Subject
的用法示例。
在下文中一共展示了Subject.startWith方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: constructor
constructor(element: HTMLElement, currentFrame$: Observable<IFrame>, renderMode: RenderMode) {
this._element = element;
this._currentFrame$ = currentFrame$;
renderMode = renderMode != null ? renderMode : RenderMode.Letterbox;
this._resize$ = new Subject<void>();
this._renderCameraOperation$ = new Subject<IRenderCameraOperation>();
this._size$ =
new BehaviorSubject<ISize>(
{
height: this._element.offsetHeight,
width: this._element.offsetWidth,
});
this._resize$
.map<ISize>(
(): ISize => {
return { height: this._element.offsetHeight, width: this._element.offsetWidth };
})
.subscribe(this._size$);
this._renderMode$ = new BehaviorSubject<RenderMode>(renderMode);
this._renderCameraHolder$ = this._renderCameraOperation$
.startWith(
(rc: RenderCamera): RenderCamera => {
return rc;
})
.scan<RenderCamera>(
(rc: RenderCamera, operation: IRenderCameraOperation): RenderCamera => {
return operation(rc);
},
new RenderCamera(this._element.offsetWidth / this._element.offsetHeight, renderMode))
.publishReplay(1)
.refCount();
this._renderCameraFrame$ = this._currentFrame$
.withLatestFrom(
this._renderCameraHolder$,
(frame: IFrame, renderCamera: RenderCamera): [IFrame, RenderCamera] => {
return [frame, renderCamera];
})
.do(
(args: [IFrame, RenderCamera]): void => {
let frame: IFrame = args[0];
let rc: RenderCamera = args[1];
let camera: Camera = frame.state.camera;
if (rc.alpha !== frame.state.alpha ||
rc.zoom !== frame.state.zoom ||
rc.camera.diff(camera) > 0.00001) {
let currentTransform: Transform = frame.state.currentTransform;
let previousTransform: Transform =
frame.state.previousTransform != null ?
frame.state.previousTransform :
frame.state.currentTransform;
let previousNode: Node =
frame.state.previousNode != null ?
frame.state.previousNode :
frame.state.currentNode;
rc.currentAspect = currentTransform.basicAspect;
rc.currentPano = frame.state.currentNode.fullPano;
rc.previousAspect = previousTransform.basicAspect;
rc.previousPano = previousNode.fullPano;
rc.alpha = frame.state.alpha;
rc.zoom = frame.state.zoom;
rc.camera.copy(camera);
rc.updatePerspective(camera);
rc.updateProjection();
}
rc.frameId = frame.id;
})
.map<RenderCamera>(
(args: [IFrame, RenderCamera]): RenderCamera => {
return args[1];
})
.publishReplay(1)
.refCount();
this._renderCamera$ = this._renderCameraFrame$
.filter(
(rc: RenderCamera): boolean => {
return rc.changed;
})
.publishReplay(1)
.refCount();
this._size$
.skip(1)
.map<IRenderCameraOperation>(
//.........这里部分代码省略.........