re: 60fps with Functional Programming in idle time VIEW POST

re: Thanks. Actually I do some minor data manipulation on arrival (e.g. lodash/fp "keyBy" s.o) then dispatch to Redux Store. I'll check it deeper and i...

Ok that keyBy might be an issue if the data is huge. You/I/we could do a version of keyBy that uses reduceAsync and that would split it up over frames. Fundamentally that would probably look like this:

function keyByAsync(items, predicate) {

    return reduceAsync(items, reducer, {})
    function reducer(acc, cur) {
        acc[predicate(cur)] = cur
        return acc

      await keyByAsync(yourArray, v=>v.somethingOrOther)

That's making a single lookup rather than a key to array - but it sounds like this is what you are after. It's a useful function, I may clean it and a few others like groupBy and add them. Basically anything that takes a while benefits from going through one of the async functions which yield every 8 times (by default) to see if there is still time.

Yes! It has to be this. The keyBy is really needed as the reducer was built that way for O1 access with selector and so on... I will try to put up something here to test but I am pretty sure that your keyByAsync would be much reliable than mine:) So I will stay tuned for update. Thanks a lot!

Totally makes sense to me. Ok I'll sort it over the next few days.

code of conduct - report abuse