* Evaluates a single expression and returns its result. * @param {string} expression * @param {!JsonObject} scope * @return {!Promise<!JsonObject>}
(expression, scope)
| 1022 | * @return {!Promise<!JsonObject>} |
| 1023 | */ |
| 1024 | evaluateExpression_(expression, scope) { |
| 1025 | return this.initializePromise_ |
| 1026 | .then(() => { |
| 1027 | // Allow expression to reference current state in addition to event state. |
| 1028 | Object.assign(scope, this.state_); |
| 1029 | return this.ww_('bind.evaluateExpression', [expression, scope]); |
| 1030 | }) |
| 1031 | .then((returnValue) => { |
| 1032 | const {error, result} = returnValue; |
| 1033 | if (error) { |
| 1034 | // Throw to reject promise. |
| 1035 | throw this.reportWorkerError_( |
| 1036 | error, |
| 1037 | `${TAG}: Expression eval failed.` |
| 1038 | ); |
| 1039 | } else { |
| 1040 | return result; |
| 1041 | } |
| 1042 | }); |
| 1043 | } |
| 1044 | |
| 1045 | /** |
| 1046 | * Reevaluates all expressions and returns a map of expressions to results. |
no test coverage detected