Skip to content

@toggleAll

Negate every signal whose path matches a filter: each one becomes !value. Like @setAll, but relative.

@toggleAll({ include: /^flags\./ })
@toggleAll() // every signal
toggle both

<div data-signals="{ t: { x: true, y: false } }">
<div class="row"><label><input type="checkbox" data-bind:t.x> x</label><label><input type="checkbox" data-bind:t.y> y</label> <button data-on:click="@toggleAll({ include: /^t\./ })">invert</button></div>
<pre data-text="JSON.stringify($t)"></pre>
</div>

Toggle every open.* flag that drives a set of collapsibles.

sections
Section A

Contents of A.

Section B

Contents of B.

Section C

Contents of C.

<div data-signals="{ open: { a: true, b: false, c: false } }">
<button data-on:click="@toggleAll({ include: /^open\./ })">flip all sections</button>
<div style="margin-top:.5rem"><b>Section A</b><div data-collapse="$open.a"><p class="muted" style="margin:.2rem 0 .5rem">Contents of A.</p></div></div>
<div><b>Section B</b><div data-collapse="$open.b"><p class="muted" style="margin:.2rem 0 .5rem">Contents of B.</p></div></div>
<div><b>Section C</b><div data-collapse="$open.c"><p class="muted" style="margin:.2rem 0 .5rem">Contents of C.</p></div></div>
</div>

Non-boolean values are negated by JavaScript rules (0 becomes true, a non-empty string becomes false), so keep the filter on boolean paths. Runs in one batch; computed paths are skipped.

import { toggleAll } from 'sigmx/plugins'

Registering toggleAll adds 87 bytes brotli (98 gzip, 221 minified) on top of the core. See bundle sizes.