Skip to content

Instantly share code, notes, and snippets.

@jasonkarns
Created November 16, 2013 03:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasonkarns/7495384 to your computer and use it in GitHub Desktop.
Save jasonkarns/7495384 to your computer and use it in GitHub Desktop.
What if _.tap could set the context of the interceptor? I would imagine that it would set the context to the tapped object by default. I can't think of a use case for setting it to another arbitrary object.
# the thought came to me when dealing with angular
myModule = angular.module('myModule', [])
myModule.value 'X', X
myModule.factory 'F', F
myModule.service 'S', S
# with tap, but without setting context
_(angular.module('myModule', [])).tap (myModule) ->
myModule.value 'X', X
myModule.factory 'F', F
myModule.service 'S', S
# with tap and assuming that context is set to the tapped object automatically
_(angular.module('myModule', [])).tap ->
@value 'X', X
@factory 'F', F
@service 'S', S
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment