These are chat archives for ramda/ramda

16th
May 2018
Shane Keulen
@SeeThruHead
May 16 2018 16:06
const storageLens = R.lens(
  () => {
    return JSON.parse(window.localStorage.getItem(storageKey)) || {};
  },
  value => {
    return window.localStorage.setItem(storageKey, JSON.stringify(value));
  }
);

console.log(R.view(storageLens, undefined));
R.over(storageLens, R.assoc('bob', true), undefined);
console.log(R.view(storageLens, undefined));
R.over(storageLens, R.assoc('bob', true), undefined);
is there a nicer way to do this (use a lens that doesn't require data to be passed in)
Ivan Serniaev
@delorge
May 16 2018 17:52

Hi everyone, can anyone help me with following: is it possible to use memoized functions with functors? I've tried to use it with converge like this(simplified):

const res = R.converge(R.equals, [notMemoizedFn, memoizedFn])

as subsequent calls of memoized function return value immediately, internals of ramda throw being unable to use apply. any thoughts?

Brad Compton (he/him)
@Bradcomp
May 16 2018 18:02
@delorge There might be something else going on, can you produce an example? https://goo.gl/2FquNh
Ivan Serniaev
@delorge
May 16 2018 18:06
@Bradcomp thank you for quick response! hm, seems like something else is going wrong in my case
A
@dizzyone
May 16 2018 21:05
Hi guys, I haven't been using ramda for a couple of months and gotten rusty, I have a question: given 2 arrays of objects, how do I combine them into one keyed object like so: https://goo.gl/LJBUKv
Mike Lambert
@lax4mike
May 16 2018 21:08
you can probably use R.groupBy
something like this:
R.compose(
  R.map(R.reduce(R.merge, {})),
  R.groupBy(R.prop("id"))
)(R.concat(controlItems, contentItems))
A
@dizzyone
May 16 2018 21:48
thanks @lax4mike . Gotta get back into it :)
Mike Lambert
@lax4mike
May 16 2018 21:51
👍