本文整理汇总了TypeScript中rxjs/BehaviorSubject.BehaviorSubject.map方法的典型用法代码示例。如果您正苦于以下问题:TypeScript BehaviorSubject.map方法的具体用法?TypeScript BehaviorSubject.map怎么用?TypeScript BehaviorSubject.map使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rxjs/BehaviorSubject.BehaviorSubject
的用法示例。
在下文中一共展示了BehaviorSubject.map方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: function
export default function(options: CanvasOptions) {
const write = new Subject<DragDeltaLog>();
const clear = new Subject<any>();
const scale = new BehaviorSubject<any>(true);
const toggle = new Subject<any>();
const canvas = options.canvasElement as HTMLCanvasElement;
const context = canvas.getContext("2d");
if (context === null) {
throw new TypeError('unreachable: canvas should be not `null`');
}
write.subscribe(writeCanvasTo(context, options.color));
clear.subscribe(clearCanvasTo(context));
scale
.map(() => window.innerWidth)
.subscribe(attributeAssignOf(canvas, 'width'));
scale
.map(() => window.innerHeight)
.subscribe(attributeAssignOf(canvas, 'height'));
toggle
.scan((acc) => !acc, false)
.map((bool) => bool ? 'false' : 'true')
.subscribe(attributeAssignOf(canvas, 'aria-hidden'));
return {
cvWrite : write,
cvClear : clear,
cvToggle : toggle,
cvScale : scale
};
}
示例2: function
/**
* compute ratio
*/
export default function(options: ResponsiveOptions) {
const scaleSubject = new BehaviorSubject<any>(true);
const scaleFn = compose(centeringOf(options.target), scalingOf(options.target));
const hRatio = scaleSubject.map(horizontalRatioOf(options.width));
const vRatio = scaleSubject.map(verticalRatioOf(options.height));
const currentRatio = Observable.combineLatest(hRatio, vRatio).map((hv) => Math.min(hv[0], hv[1]));
currentRatio.subscribe(scaleFn);
return {
scale : scaleSubject,
currentRatio : currentRatio
};
}
示例3: function
/**
* paging control
*/
export default function(options: PagingOptions) {
const next = new Subject<any>();
const prev = new Subject<any>();
const move = new Subject<number>();
const current = new BehaviorSubject<number>(options.startPage || 1);
const currentPage: Observable<number> = current
.map(inRangeOf(1, options.endPage))
.distinctUntilChanged();
const _next = next.withLatestFrom(currentPage, (_, page) => page).map((v) => v + 1);
const _prev = prev.withLatestFrom(currentPage, (_, page) => page).map((v) => v - 1);
const _move = move.map((v) => v /* noop */);
const percentString = currentPage.map(percentOf(options.endPage));
const currentSlide = currentPage.map((i) => options.slideElements[i - 1]);
Observable.merge(_next, _prev, _move).subscribe(current);
currentSlide.subscribe(function(current) {
options.slideElements.forEach(toInvisible);
current && toVisible(current);
});
return {
current : currentPage,
start : currentPage.filter((v) => v === 1),
end : currentPage.filter((v) => v === options.endPage),
changed : currentSlide,
percent : percentString,
next : next,
prev : prev,
move : move
};
}