These are chat archives for ramda/ramda

13th
Jun 2016
David Langford
@That-David-Guy
Jun 13 2016 00:17
Though I am using import
Tushar Mathur
@tusharmath
Jun 13 2016 14:55
export const DownloadFromMeta = ({HTTP, meta$}) => {
  const threads = (meta) => meta.threads.map((_, index) => ({meta, index}))
  const Offset = ({meta, index}) => meta.offsets[index]
  return R.compose(
    Rx.shareReplay(1),
    Rx.flatMap(({meta, index}) => {
     // Refactor to make it simpler
      const addIndex = R.merge({index})
      const offset = Offset({meta, index})
      const requestParams = CreateRequestParams({meta, index})
      return R.compose(Rx.map(addIndex), RequestDataOffsetKV)({HTTP, requestParams, offset})
    }),
    Rx.flatMap(threads)
  )(meta$)
}
I am trying to make this code inside of flatMap simpler.
Is there some useful function that I can use from Ramda that can make some significant changes
Tushar Mathur
@tusharmath
Jun 13 2016 15:05
I particularly want the two functions — CreateRequestParams and RequestDataOffsetKV out of this function. They are already being unit tested and testing DownloadFromMeta retests those functions.
LeonineKing1199
@LeonineKing1199
Jun 13 2016 20:20
I don't see how you could pull those functions out. Out of curiosity, what is it that you're hoping Ramda will do for you in this instance? You're creating a flatMap out of a function composition. What would you hope Ramda do for you?
LeonineKing1199
@LeonineKing1199
Jun 13 2016 20:26
Well, if the function you're feeding to Rx.flatMap doesn't rely on any type of variable capturing, you could pull it out of the function you're using it in. You might be able to instantiate the composition at require time.