let/count=0
button onClick() {
count++;
}
-- Current: ${count}
Here, a count
Tag Variable is mutated by a button click. Because the text content of the button references count
, it is automatically be kept in sync with the new value.
Caution
In some cases Marko may cause some expressions to evaluate together. This is why render expressions should be pure.
Tip
Marko is a compiled language, and its reactive graph is discovered at compile time instead of during runtime. This is in contrast with many of the other leading approaches, such as Signals in SolidJS and Hooks in React.
Marko automatically batches work to ensure optimal performance. Any time a reactive variable is changed, its update is queued to ensure that multiple changes will be applied efficiently together.
This update queue is typically scheduled after a microtask.
If additional updates are scheduled after the queue is consumed but before the update is painted, they are deferred until the next frame. This accomplishes a few things:
Helpful? You can thank these awesome people! You can also edit this doc if you see any issues or want to improve it.