Created
May 21, 2022 00:58
-
-
Save julienetie/77877ad18928a654ed725bb9200243fd to your computer and use it in GitHub Desktop.
Anti-framework example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { pasteInto } from '../../anti-framework.js' | |
let n = 0 | |
// The view callback prevents conditions and loops and operators at runtime. | |
const counterView = pasteInto('#root', ({ n }) => ` | |
<button value="-">-</button> | |
<button value="+">+</button> | |
<span>${n}</span> | |
`) | |
// Below is controller logic Zzz | |
document.addEventListener('mousedown', ({ target }) => { | |
if (target.value === '+') n++; if (target.value === '-') n-- | |
counterView({ n }) | |
}) | |
counterView({ n }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment