jasonkarns
11/16/2013 - 3:00 AM

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

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