question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Handler code wrapped in @(...)?

See original GitHub issue

In the second step, the event handler code is wrapped in an additional @(...) construct:

@onclick="@(() => Console.WriteLine(special.Name))"

Can you explain why? It seems to work without problems with just

@onclick="() => Console.WriteLine(special.Name))"

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
jessegoodcommented, Nov 24, 2021

@lohithgn To me, the current examples are not consistent though in there use of parentheses:

Without parentheses: <span class="topping-price">@topping.Topping.GetFormattedPrice()</span>

With parentheses: Price: <span class="price">@(Pizza.GetFormattedTotalPrice())</span>

With and without? <div class="title">@(Pizza.Size)" @Pizza.Special.Name</div>

When you say opt for explicit razor expressions, what are your guidelines for using them?

0reactions
jessegoodcommented, Dec 20, 2021

@jessegood I see. Let me try to explain again. Basically, I would prefer implicit expressions over explicit unless the parser requires them. So in the example that you copied from my question, I would make it: <span class="price">@Pizza.GetFormattedTotalPrice()</span> and not <span class="price">@(Pizza.GetFormattedTotalPrice())</span>

My question was why prefer the latter over the former, as it doesn’t make the code easier to understand.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Wrap the event handler in JQuery - javascript
It means I'd like to wrap the current event handlers with some extra codes. I'd like to call the old code with setTimeOut()...
Read more >
Attribute::Handlers to wrap a function
The Wrap function is marked to be a attribute handler for subroutines (CODE). Inside we create a new anonymous subroutine and assign it...
Read more >
Wrap Your Lambda Handler in Code
For Python and Node.js Lambda functions, in order to instrument individual invocations, the Datadog Lambda library needs to wrap around your Lambda handler...
Read more >
io.undertow.server.HandlerWrapper.wrap java code ...
Best Java code snippets using io.undertow.server.HandlerWrapper.wrap (Showing top 20 results out of 315) · Popular methods of HandlerWrapper · Popular in Java.
Read more >
JavaScript for C# programmers: wrapping an existing function ...
My solution to the problem involved adding some extra precondition code to an existing event handler. The event was the plotclick event of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found