V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
CraxClive
V2EX  ›  问与答

问个关于 RxJS 的问题

  •  
  •   CraxClive · Aug 7, 2020 · 1400 views
    This topic created in 2100 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   ·   1576 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 16:41 · PVG 00:41 · LAX 09:41 · JFK 12:41
    ♥ Do have faith in what you're doing.