(scope, listener, objectEquality, parsedExpression, prettyPrintExpression)
| 17530 | } |
| 17531 | |
| 17532 | function oneTimeWatchDelegate(scope, listener, objectEquality, parsedExpression, prettyPrintExpression) { |
| 17533 | var isDone = parsedExpression.literal ? isAllDefined : isDefined; |
| 17534 | var unwatch, lastValue; |
| 17535 | |
| 17536 | var exp = parsedExpression.$$intercepted || parsedExpression; |
| 17537 | var post = parsedExpression.$$interceptor || identity; |
| 17538 | |
| 17539 | var useInputs = parsedExpression.inputs && !exp.inputs; |
| 17540 | |
| 17541 | // Propogate the literal/inputs/constant attributes |
| 17542 | // ... but not oneTime since we are handling it |
| 17543 | oneTimeWatch.literal = parsedExpression.literal; |
| 17544 | oneTimeWatch.constant = parsedExpression.constant; |
| 17545 | oneTimeWatch.inputs = parsedExpression.inputs; |
| 17546 | |
| 17547 | // Allow other delegates to run on this wrapped expression |
| 17548 | addWatchDelegate(oneTimeWatch); |
| 17549 | |
| 17550 | unwatch = scope.$watch(oneTimeWatch, listener, objectEquality, prettyPrintExpression); |
| 17551 | |
| 17552 | return unwatch; |
| 17553 | |
| 17554 | function unwatchIfDone() { |
| 17555 | if (isDone(lastValue)) { |
| 17556 | unwatch(); |
| 17557 | } |
| 17558 | } |
| 17559 | |
| 17560 | function oneTimeWatch(scope, locals, assign, inputs) { |
| 17561 | lastValue = useInputs && inputs ? inputs[0] : exp(scope, locals, assign, inputs); |
| 17562 | if (isDone(lastValue)) { |
| 17563 | scope.$$postDigest(unwatchIfDone); |
| 17564 | } |
| 17565 | return post(lastValue); |
| 17566 | } |
| 17567 | } |
| 17568 | |
| 17569 | function isAllDefined(value) { |
| 17570 | var allDefined = true; |
nothing calls this directly
no test coverage detected