You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I like bitmasked enums. They consume very little RAM and working with them is super fast. I often build a bunch of checkboxes that represent an option (bitmasked value).
Describe the proposed solution
Just to be able to do bind:group using a number and bit values:
<script>
// Statelet options =$state(0);// Or directly as a prop is more desirable:let { options =$bindable(0), } =$props();
</script>
{#each [1, 2, 4, 8] asbit}
<label>
<inputtype="checkbox"value={bit} bind:group={options}>{bit}
</label>
{/each}
Svelte could detect my options variable is a number and therefore assume that all values in the bound checkboxes will be numbers that are added or removed using bitwise operators.
Importance
nice to have
The text was updated successfully, but these errors were encountered:
Also, does function binding work for bind:checked? I also wanted a bind:unchecked, but I guess that if function binding works with bind:checked I can easily simulate my wanted bind:unchecked.
Thanks, @brunnerh . I did notice. I was going to open one, but analyzing how bind:group works I figured most likely it was by design, and therefore a mere documentation issue.
BTW, I just tested bind:checked with functions and it does work to easily simulate my wanted bind:unchecked. If anyone is curious:
<script>
let name ='world';let isUnchecked =$state(false)
</script>
<inputtype="checkbox"bind:checked={() =>!isUnchecked, (v) =>isUnchecked=!v}>
<pre>{isUnchecked}</pre>
Describe the problem
I like bitmasked enums. They consume very little RAM and working with them is super fast. I often build a bunch of checkboxes that represent an option (bitmasked value).
Describe the proposed solution
Just to be able to do
bind:group
using a number and bit values:Svelte could detect my
options
variable is a number and therefore assume that all values in the bound checkboxes will be numbers that are added or removed using bitwise operators.Importance
nice to have
The text was updated successfully, but these errors were encountered: