These are chat archives for jdubray/sam

28th
Mar 2017
Rodrigo Carranza
@DrecDroid
Mar 28 2017 01:22
Sometimes I miss Dart's null aware operator. a??=b is the same as a=a!=null?a:b, and a=b??c is the same as a= b!=null?b:c, and the other one for safe access a?.b?.c
It helps a lot to handle mutations
Jean-Jacques Dubray
@jdubray
Mar 28 2017 14:15
@schtauffen I think he speaks about replacing if-then-else with (condition) ? ... : ... (if I recall correctly).
Jean-Jacques Dubray
@jdubray
Mar 28 2017 14:24
I think the problem with if-then-else is not so much the construct, it is it's misuse. It's too easy to sprinkle if-then-else all over your code when it should be reserved state-transitions (aka next action).
Jean-Jacques Dubray
@jdubray
Mar 28 2017 15:03
@devinivy It would be nice to introduce a "present" method for the function tree context... It's not wise to arbitrarily modify the context within any given function.. :-)
function funcA(context) {
  return new Promise(resolve => {
    setTimeout(resolve, 500)
  })
}

function funcB(context) {
  if (context.input.retryCount < 3) {
    return context.execution.retry({
      retryCount: context.input.retryCount + 1
    })
  }
}

const tree = [
  funcA,
  funcB
]

execute(tree, {
  retryCount: 0
})
devin ivy
@devinivy
Mar 28 2017 15:17
:)