Skip to content

Instantly share code, notes, and snippets.

@rk
Last active October 21, 2021 21:00
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 rk/168788377cc6ffd29aa00ed1cde3c416 to your computer and use it in GitHub Desktop.
Save rk/168788377cc6ffd29aa00ed1cde3c416 to your computer and use it in GitHub Desktop.
Million Patch Problem
<!DOCTYPE html>
<body>
<div id="app"></div>
<script type="module">
import {
m,
patch,
/* or any other exports you want to access */
} from 'https://unpkg.com/million?module';
const format = new Intl.DateTimeFormat('en-us', { dateStyle: 'short', timeStyle: 'medium' });
function render() {
let now = new Date();
console.log('render', now);
patch(document.getElementById('app'), m('div', { id: "app", key: 'app' }, [
m('span', { key: 'ts' }, [format.format(now)])
]));
}
setInterval(render, 1000);
render();
</script>
</body>
<!DOCTYPE html>
<body>
<div id="app"></div>
<script type="module">
import {
m,
patch,
/* or any other exports you want to access */
} from 'https://unpkg.com/million?module';
const format = new Intl.DateTimeFormat('en-us', { dateStyle: 'short', timeStyle: 'medium' });
function render() {
let now = new Date();
console.log('render', now);
patch(document.getElementById('app'), m('div', { id: "app" }, [
m('span', {}, [format.format(now)])
]));
}
setInterval(render, 1000);
render();
</script>
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment