V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
CraxClive
V2EX  ›  问与答

问个关于 RxJS 的问题

  •  
  •   CraxClive · 2020-08-07 12:31:23 +08:00 · 1017 次点击
    这是一个创建于 1356 天前的主题,其中的信息可能已经有所发展或是发生改变。

    不使用 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 条回复    2020-08-07 19:46:15 +08:00
    Zhuzhuchenyan
        1
    Zhuzhuchenyan  
       2020-08-07 19:46:15 +08:00
    换汤不换药的推荐 withlatestfrom, 不过这个操作符分主次,根据你要的逻辑写就好了
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5357 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 05:54 · PVG 13:54 · LAX 22:54 · JFK 01:54
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.