protected override void DefaultVisit(JsNode node)
 {
     if (node is JsExpression expression && node.HasAnnotation <ResultIsObservableAnnotation>() && !node.Parent.HasAnnotation <ObservableUnwrapInvocationAnnotation>() && !(node.Role == JsAssignmentExpression.LeftRole && node.Parent is JsAssignmentExpression) && node.Parent != null)
     {
         if (!AllowObservableResult || !node.IsRootResultExpression())
         {
             // may be null is copied to the observable result
             node.ReplaceWith(_ => KoUnwrap(expression, expression, false));
             node.RemoveAnnotations <MayBeNullAnnotation>();
         }
     }
     base.DefaultVisit(node);
 }
Beispiel #2
0
        private void HandleNode(JsNode node)
        {
            if (node is JsExpression expression2)
            {
                foreach (var transform in node.Annotations.OfType <ObservableTransformationAnnotation>())
                {
                    node.ReplaceWith(_ => transform.TransformExpression(expression2));
                }
            }

            if (node is JsExpression expression && IsObservableResult(node) && !node.Parent.HasAnnotation <ObservableUnwrapInvocationAnnotation>() && !(node.Role == JsAssignmentExpression.LeftRole && node.Parent is JsAssignmentExpression) && node.Parent != null)
            {
                if (ShouldUnwrap(node))
                {
                    // may be null is copied to the observable result
                    node.ReplaceWith(_ => KoUnwrap(expression, expression, !node.HasAnnotation <ResultIsObservableAnnotation>()));
                    node.RemoveAnnotations <MayBeNullAnnotation>();
                }
                else
                {
                    // may be null means that the value in the observable may be null. Which is not unwrapped, so the annotation is removed.
                    node.RemoveAnnotations <MayBeNullAnnotation>();
                }
            }
 protected override void DefaultVisit(JsNode node)
 {
     if (node is JsExpression expression && IsObservableResult(node) && !node.Parent.HasAnnotation <ObservableUnwrapInvocationAnnotation>() && !(node.Role == JsAssignmentExpression.LeftRole && node.Parent is JsAssignmentExpression) && node.Parent != null)
     {
         if (ShouldUnwrap(node))
         {
             // may be null is copied to the observable result
             node.ReplaceWith(_ => KoUnwrap(expression, expression, !node.HasAnnotation <ResultIsObservableAnnotation>()));
             node.RemoveAnnotations <MayBeNullAnnotation>();
         }
         else
         {
             // may be null means that the value in the observable may be null. Which is not unwrapped, so the annotation is removed.
             node.RemoveAnnotations <MayBeNullAnnotation>();
         }
     }