-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: ♻️ add pipeline operator support #318
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,14 @@ | ||
// @flow | ||
import { flatten, map, pipe, prop, uniq } from 'ramda' | ||
import { flatten, map, prop, uniq } from 'ramda' | ||
|
||
interface IEvent { | ||
date: Date; | ||
} | ||
|
||
const viewTags = talk => (talk.tags ? talk.tags : []) | ||
|
||
export let eventTags = pipe( | ||
prop('talks'), | ||
map(viewTags), | ||
flatten, | ||
uniq, | ||
) | ||
export let eventTags = e => | ||
e |> prop('talks') |> map(viewTags) |> flatten |> uniq | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In my opinion, this repetition There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. agree There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That is because rambda's pipe and native pipeline operator do different things, but use same name. So e.g. in Elm you have two options: composition using << operatior and create pipelines using |> operator. Through my humble experience in elm, I learn that it is better use pipeline operator when we need the value now (e.g. in render function in react), because it doesn't support delayed evaluation. In this case it reads super awesome. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also in ReasonML doesn't support composition, and only pipelines. JFYI. Feels unnatural from the very beginning. But used to it almost instantly |
||
|
||
let getEventNode = (event: { node: * }) => event.node | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting 🔥
But tt still seems to me that
pipe(/***/)
using is more informative. Maybe because|>
operator is very new and rare for me.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should always strive for using native implementation of functions and methods etc.
🚀🚀🚀🚀