Created
February 2, 2021 08:38
-
-
Save audinue/00bb25483fbea5ce629d3b83c43d8a42 to your computer and use it in GitHub Desktop.
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
<script> | |
// Data abstracts storage | |
let Data = { | |
_count: 0, | |
get count () { | |
return Data._count | |
}, | |
set count (value) { | |
Data._count = value | |
} | |
} | |
// Logic abstracts Data | |
let Logic = { | |
get count () { | |
return Data.count | |
}, | |
increment () { | |
Data.count++ | |
} | |
} | |
// Presentation presents Logic | |
let Presentation = { | |
index () { | |
Presentation.render() | |
}, | |
increment () { | |
Logic.increment() | |
Presentation.render() | |
}, | |
render () { | |
document.title = 'Counter' | |
document.body.innerHTML = ` | |
<button onclick="Presentation.increment()"> | |
Count: ${Logic.count} | |
</button> | |
` | |
} | |
} | |
addEventListener('DOMContentLoaded', Presentation.index) | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment