-
-
Save anonymous/cb509cc3ad2ffbae86b6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
zoosk.services.shared.SafeApplyFactoryFactory = function($rootScope) { | |
return function safeApplyFactory(fn, opt_context, var_args) { | |
var factoryArgs = [].slice.call(arguments, 2); | |
return function safeApplyWrapper() { | |
var factoryAndWrapperArgs = factoryArgs.concat([].slice.call(arguments)); | |
var fnCall = typeof(fn) == 'function' ? function() { | |
return fn.apply(opt_context, factoryAndWrapperArgs); | |
} : angular.noop; | |
var phase = $rootScope.$root.$$phase; | |
if (phase != '$apply' && phase != '$digest') { | |
return $rootScope.$apply(fnCall); | |
} | |
return fnCall(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment