Search code examples
frpbacon.js

A property that depends on other properties


All

I often find myself writing the code like following:

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

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

);

To me it looks like a sort of DRY violation and poor readability. How could the code above be improved?


Solution

  • Why not

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

    Or

    let C = A.combine(B, getC)
    

    ... which is equivalent.