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

Alternate name for deferred.node() #55

Closed
kriskowal opened this issue Apr 18, 2012 · 4 comments
Closed

Alternate name for deferred.node() #55

kriskowal opened this issue Apr 18, 2012 · 4 comments

Comments

@kriskowal
Copy link
Owner

Alex Raschmeyer recommends that we reconsider the name of the node callback function.

http://www.2ality.com/2012/04/expand-urls.html

For what it’s worth, the callback could always be the same object and thus it would make sense for it to be a property rather than a function, but it would incur the cost of generate such a function for every deferred. That is why it is a function. Alternate approaches could simulate a property in some cases.

@domenic
Copy link
Collaborator

domenic commented Apr 18, 2012

To get the bikeshedding out of the way: createNodeCallback or asNodeCallback are most to my liking.

I think generating it on each call (and thus being a function instead of a property) makes the most sense, as it seems very rare to want to get the callback more than once.

I suppose for browsers that support getters we could add a nodeCallback lazily-computed property, but I don't know if I liking having a variable API surface depending on environment.

@kriskowal
Copy link
Owner Author

Please feel free to shoot down this idea: deferred.nodeback()

@domenic
Copy link
Collaborator

domenic commented Apr 18, 2012

I... kind of like it. Why isn't anyone using that term already?

@rauschma
Copy link

My proposal: createNodejsCallback. Rationale:

  • Makes it obvious that a new object is created for each invocation.

  • Callback is more self-explanatory than back.

  • The same holds for node versus nodejs. Especially with the DOM, node can mean many things.

  • @domenic mentions as as an alternative to create. Another possibility is resolveVia:

    deferred.resolveViaNodejsCallback
    

Having a long identifier here is a feature (not a bug ;-), because that method is so powerful and does so much. Then we want its name to be descriptive.

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

No branches or pull requests

3 participants