(scope, listener, objectEquality, parsedExpression, prettyPrintExpression)
| 16891 | } |
| 16892 | |
| 16893 | function oneTimeWatchDelegate(scope, listener, objectEquality, parsedExpression, prettyPrintExpression) { |
| 16894 | var isDone = parsedExpression.literal ? isAllDefined : isDefined; |
| 16895 | var unwatch, lastValue; |
| 16896 | |
| 16897 | var exp = parsedExpression.$$intercepted || parsedExpression; |
| 16898 | var post = parsedExpression.$$interceptor || identity; |
| 16899 | |
| 16900 | var useInputs = parsedExpression.inputs && !exp.inputs; |
| 16901 | |
| 16902 | // Propogate the literal/inputs/constant attributes |
| 16903 | // ... but not oneTime since we are handling it |
| 16904 | oneTimeWatch.literal = parsedExpression.literal; |
| 16905 | oneTimeWatch.constant = parsedExpression.constant; |
| 16906 | oneTimeWatch.inputs = parsedExpression.inputs; |
| 16907 | |
| 16908 | // Allow other delegates to run on this wrapped expression |
| 16909 | addWatchDelegate(oneTimeWatch); |
| 16910 | |
| 16911 | unwatch = scope.$watch(oneTimeWatch, listener, objectEquality, prettyPrintExpression); |
| 16912 | |
| 16913 | return unwatch; |
| 16914 | |
| 16915 | function unwatchIfDone() { |
| 16916 | if (isDone(lastValue)) { |
| 16917 | unwatch(); |
| 16918 | } |
| 16919 | } |
| 16920 | |
| 16921 | function oneTimeWatch(scope, locals, assign, inputs) { |
| 16922 | lastValue = useInputs && inputs ? inputs[0] : exp(scope, locals, assign, inputs); |
| 16923 | if (isDone(lastValue)) { |
| 16924 | scope.$$postDigest(unwatchIfDone); |
| 16925 | } |
| 16926 | return post(lastValue); |
| 16927 | } |
| 16928 | } |
| 16929 | |
| 16930 | function isAllDefined(value) { |
| 16931 | var allDefined = true; |
nothing calls this directly
no test coverage detected