Skip to content

Commit

Permalink
refactor: use lodash.get to extract service
Browse files Browse the repository at this point in the history
  • Loading branch information
Guria committed Jul 15, 2016
1 parent eafcf38 commit cb8ce8a
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,16 +191,9 @@ function Router (routesConfig, options) {
}
}

var getRouterServices = function (context) {
var modulePath = context[MODULE].path
return modulePath.reduce(function (services, key) {
return services[key]
}, context.services)
}

Router.redirect = function (url, params) {
function action (context) {
var services = getRouterServices(context)
function action (ctx) {
var services = get(ctx.services, ctx[MODULE].path)

return services.redirect(url, params)
}
Expand Down

0 comments on commit cb8ce8a

Please sign in to comment.