o => o.selected
could be R.prop('selected')
I guess.
R.pipe
or R.compose
instead of data => ...(data)
@manniL I'm not sure if it's better (it's probably not as easy to grok) but I had a go at your earlier question:
const isShiftAction = propEq('shift', true); const isNotShiftAction = complement(isShiftAction); const appendTo = flip(append) const willBeUsedAsReduceFunction = shifts => ifElse( both( compose(isShiftAction, head), compose(isNotShiftAction, last) ), compose(appendTo(shifts), head), always(shifts) ) willBeUsedAsReduceFunction([])([{ shift: true }, {}])
@ben-eb Just tried out your proposal :relaxed:
console.log(reduce(willBeUsedAsReduceFunction, [], [{shift: true}, {}]))
returns a function
getActive(types)
an object?
const get = pipe(find(prop('selected')), prop('value'));
this.setState({
types: get(types),
addresses: get(addresses),
...
})
Of course, get
is a terrible function name, so change that to suit your app. Also, there's no error handling, in case the results of find
is undefined
.
.reduce
calls that happen behind the scenes with every composed (pipe
/compose
) function's invocation.
list
is great. It was created by @paldepind, a Ramda core team member and contributor to FantasyLand, as well as the creator of Flyd.
uncurryN
to remove the manual currying there - so uncurryN(2, willBeUsedAsReduce)
@rakeshpai: Note that in that code, your Maybe
is not entirely fantasy-land compatible.
1.i No parts of
a
should be checked
-- Applicative's of
method.
Just(null)
as a legitimate value.