A property that depends on other properties

40 views Asked by At

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?

1

There are 1 answers

0
raimohanska On BEST ANSWER

Why not

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

Or

let C = A.combine(B, getC)

... which is equivalent.