Skip to content
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

route syntax sugar improvement, eliminate side effects #49

Merged
merged 4 commits into from
Jan 13, 2016

Conversation

kristofsajdak
Copy link
Contributor

Looking back at the harvester.route (e.g. readonly, immutable... ) methods I now feel that it's making things complex and rigid with not enough benefit.

As part of this change I removed the side-effecting harvester.route functions in favour of pure functions which got added to harvester.routes alongside with the singular route methods (e.g. get, post...)

Rather than

harvester.route.readonly(brands) 

we now declare

_.map(harvester.routes.readonly(brands), (route) => server.route(route))

and analogue

_.map(harvester.routes.all(brands), (route) => server.route(route))
_.map(harvester.routes.readonly(brands), (route) => server.route(route))
_.map(harvester.routes.immutable(brands), (route) => server.route(route))

It's a bit more verbose but composes a lot better, as it allows the resulting route object literals to be passed around and transformed with libs such as lodash and (ramdbajs)[http://ramdajs.com/]

… harvester.routes. e.g. harvester.route.readonly(brands) -> _.map(harvester.routes.readonly(brands), (route) => server.route(route))

this leaves more room for composition, allowing the resulting route object literals to be passed around and transformed with libs such as lodash and ramdbajs
mavdi added a commit that referenced this pull request Jan 13, 2016
route syntax sugar improvement, eliminate side effects
@mavdi mavdi merged commit db968c0 into develop Jan 13, 2016
@mavdi mavdi deleted the feature/route-syntax-sugar-improvement branch January 13, 2016 16:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants