Skip to content

Conversation

@Jabher
Copy link
Contributor

@Jabher Jabher commented May 19, 2015

E.g.

function call(url, timeout = 60) {
  return request.call(url, {timeout});
}

I think that really makes sense.
Moreover, that's a JavaScript way - "everything is exposed, except what's hidden explicitly".

I've been using this technique for a long time and it really makes sense, as it's rather common situation — when you suddenly find out you need to override some closure-stored configuration variables during the call.

E.g.
```javascript
function call(url, timeout = 60) {
  return request.call(url, {timeout});
}
```

I think that really makes sense. 
Moreover, that's a JavaScript way - "everything is exposed, except what's hidden explicitly".

I've been using this technique for a long time and it really makes sense, as it's rather common situation — when you suddenly find out you need to override some closure-stored configuration variables during the call.
@ljharb
Copy link
Collaborator

ljharb commented Dec 23, 2015

I'm concerned about this approach, primarily because if you later need to add a required argument, it becomes a breaking change (because somebody might have relied on the timeout value). However, I also am not in favor of exposing anything publicly when it's not strictly necessary.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think this is meant to be { timeout }?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants