Skip to content

Instantly share code, notes, and snippets.

@rynowak
Last active March 25, 2019 14:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rynowak/d109c8ad75d3aac5597cb5962e034b96 to your computer and use it in GitHub Desktop.
Save rynowak/d109c8ad75d3aac5597cb5962e034b96 to your computer and use it in GitHub Desktop.

Bind cases

Option 0: (current state)

<input type="text" bind="@person.Name" />
<input type="text" bind-value="@person.Name" />
<input type="text" bind-value-oninput="@person.Name" />
<input type="text" bind-value-oninput="@person.Name" format-value="..." />

Option 1:

<input type="text" @bind="@person.Name" />
<input type="text" @bind-value="@person.Name" />
<input type="text" @bind-value="(person.Name, "oninput")" />
<input type="text" @bind-value="(person.Name, "oninput", format: "...")" />

Option 2:

<input type="text" @bind="@person.Name" />
<input type="text" @bind-value="@person.Name" />
<input type="text" @bind-value-oninput="@person.Name" />
<input type="text" @bind-value-oninput(format: "...")="@person.Name" />

Option 3:

<input type="text" @bind="@person.Name" />
<input type="text" @bind-value="@person.Name" />
<input type="text" @bind-value-oninput="@person.Name" />
<input type="text" @bind-value-oninput(format: "...")="@person.Name" />

## Events

**Option 0: (current state)**

```cshtml
<button onclick="@Clicked" />
<button onclick="@Clicked" onclick-prevent-default /> 
<button onclick="@((e) => {.....})" onclick-prevent-default />
<input type="text" onkeydown="@KeyPressed" onclick-prevent-default onclick-repeat-delay="500" />

Option 1:

<button @onclick="@Clicked" />
<button @onclick="(Clicked, preventDefault: true)"/>
<button @onclick="((e) => {.....}, preventDefault: true)" />
<input type="text" @onkeydown="(@KeyPressed, preventDefault: true, repeatDelay: 500)" />

Option 2:

<button @onclick="@Clicked" />
<button @onclick(preventDefault)="@Clicked" />
<button @onclick(preventDefault)="@((e) => {.....})" /> 
<input type="text" @onkeydown(preventDefault, repeatDelay: 500)="@KeyPressed" />

Ref

Option 0: (current state)

<div ref="@foo">...</div>
<div ref-assign="@foo" />

Option 1:

<div @ref="foo">...</div>
<div @ref="(foo, assign: true)" />

Option 2:

<div @ref="foo">...</div>
<div @ref(assign)="@foo" />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment