rxjs6 控制虚线长度

那年仲夏 提交于 2020-02-26 03:21:21

 

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
  <script src="./rxjs.umd.js"></script>
  <style>
    .box {
    }
  </style>
</head>
<body>

<input type="checkbox" id="check">
<div class="box" id="box">

</div>
<script>
  const {range, interval, fromEvent} = rxjs;
  const {map,tap, mergeMap, mapTo, filter, throttleTime, debounceTime, repeat, switchMap, takeUntil} = rxjs.operators;

  const box = document.getElementById('box')
  const check = document.getElementById('check')

  const change$ = fromEvent(check, 'change').pipe(
    // map(x => x.target.checked),
    // filter(x => x === true)
  )
  const source$ = interval(100).pipe(mapTo('.'))
  change$.pipe(
    filter(x => x.target.checked),
    tap(e => console.log('tap', e)),
    mergeMap(() => source$.pipe(
      takeUntil(change$)
    ))
  ).subscribe(x => box.innerText += x)
   
</script>
</body>
</html>

 

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!