当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript BehaviorSubject.map方法代码示例

本文整理汇总了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
  };

}
开发者ID:1000ch,项目名称:Talkie,代码行数:35,代码来源:canvas.ts

示例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
  };
}
开发者ID:1000ch,项目名称:Talkie,代码行数:19,代码来源:responsive.ts

示例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
  };
}
开发者ID:1000ch,项目名称:Talkie,代码行数:39,代码来源:paging.ts


注:本文中的rxjs/BehaviorSubject.BehaviorSubject.map方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。