亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

RXJS。每隔幾秒從媒體流中獲取價值

RXJS。每隔幾秒從媒體流中獲取價值

繁花不似錦 2021-11-25 19:27:39
下面是一個對我有用的最小示例:包.json:{  …  "devDependencies": {    "css-loader": "^3.2.0",    "mini-css-extract-plugin": "^0.8.0",    "node-sass": "^4.12.0",    "optimize-css-assets-webpack-plugin": "^5.0.3",    "sass-loader": "^8.0.0",    "webpack": "^4.40.2",    "webpack-cli": "^3.3.9"  }}webpack.config.js:const path = require("path");const MiniCssExtractPlugin = require('mini-css-extract-plugin');const OptimizeCssAssetsPlugin = require('optimize-css-assets-webpack-plugin');module.exports = {  …  module: {    rules: [      { // CSS assets remaining in the pipeline (e.g. frameworks)        test: /\.css$/,        use: [          "style-loader", // or e.g. "vue-style-loader" etc. (optional)          MiniCssExtractPlugin.loader,          "css-loader"        ]      },      { // SCSS        test: /\.scss$/,        use: [          "style-loader" // (optional)          MiniCssExtractPlugin.loader,          "css-loader",          "sass-loader"        ]      }    ]  },  // Plugins  plugins: [    new MiniCssExtractPlugin({      filename: "./css/my-style.css" // relative to `output.path` by default    }),    new OptimizeCssAssetsPlugin() // construction suffices, no additional calls needed  ]};該node-sass模塊已經輸出縮小的 CSS,所以如果您知道在您的項目中不會遇到任何原始 CSS,您可以去掉OptimizeCssAssetsPlugin.
查看完整描述

2 回答

?
喵喵時光機

TA貢獻1846條經驗 獲得超7個贊

原來使用以下方法很簡單


 const curTime$ = videoStreams.currentTime$.pipe(

  throttle(() => interval(10000))

);

它不是每三分之一秒左右返回一次玩家的位置,而是通過限制它返回時間點(我分配給它的)的值。


查看完整回答
反對 回復 2021-11-25
?
哆啦的時光機

TA貢獻1779條經驗 獲得超6個贊

使用switchMap替代


“switchMap 和其他扁平化操作符之間的主要區別在于取消效果。在每次發射時,前一個內部可觀察對象(您提供的函數的結果)被取消并訂閱新的可觀察對象?!遍喿x更多關于 switchMap 的內容

import { Component } from '@angular/core';

import { interval,of } from 'rxjs';

import { flatMap,switchMap } from 'rxjs/operators';

@Component({

  selector: 'my-app',

  templateUrl: './app.component.html',

  styleUrls: [ './app.component.css' ]

})

export class AppComponent  {

  name = 'Angular';

  currentTime$ = of(1,2,3,4,5,6,7,8)

  ngOnInit() {

    const int = interval(5000);


    const subscription = int

      .pipe(switchMap(() => this.currentTime$ ))

      .subscribe(val => console.log("TIME", val));

      }

}


查看完整回答
反對 回復 2021-11-25
  • 2 回答
  • 0 關注
  • 231 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號