【问题标题】:A property that depends on other properties依赖于其他属性的属性
【发布时间】:2017-12-16 11:38:03
【问题描述】:

全部

我经常发现自己编写如下代码:

// A, B - are properties defined elsewhere.
let C = Bacon.update(
    null,

    [
        A,
        B,
        Bacon.mergeAll(A.changes(), B.changes())
    ],
    (_, a, b) => getC(a, b)

);

对我来说,这看起来像是一种 DRY 违规和可读性差。上面的代码如何改进?

【问题讨论】:

    标签: frp bacon.js


    【解决方案1】:

    为什么不

    let C = Bacon.combineWith(A, B, getC)
    

    或者

    let C = A.combine(B, getC)
    

    ...这是等价的。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-07-08
      • 1970-01-01
      • 2011-09-09
      • 2011-08-20
      • 2018-03-26
      • 2021-06-22
      • 2017-02-08
      • 2010-11-15
      相关资源
      最近更新 更多