CraxClive
V2EX  ›  问与答

问个关于 RxJS 的问题

  •  
  •   CraxClive · Aug 7, 2020 · 1441 views
    This topic created in 2116 days ago, the information mentioned may be changed or developed.

    不使用 combineLatest 怎么达到这个效果?

        const id$ = of({
          id: '123',
        }).pipe(pluck('id'))
    
        const source$ = of({
          '123': 1,
          '234': 2,
        })
    
        combineLatest(source$, id$, (hash, id) => {
          return hash[id]
        }).subscribe(console.log)
        
    
    1 replies    2020-08-07 19:46:15 +08:00
    Zhuzhuchenyan
        1
    Zhuzhuchenyan  
       Aug 7, 2020
    换汤不换药的推荐 withlatestfrom, 不过这个操作符分主次,根据你要的逻辑写就好了
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1076 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 35ms · UTC 18:05 · PVG 02:05 · LAX 11:05 · JFK 14:05
    ♥ Do have faith in what you're doing.