DE version is available. Content is displayed in original English for accuracy.
Advertisement
Advertisement
⚡ Community Insights
Discussion Sentiment
88% Positive
Analyzed from 643 words in the discussion.
Trending Topics
#ctx#count#mador#write#read#proxies#without#great#dependency#where

Discussion (19 Comments)Read Original on HackerNews
```js import mador from "mador"; const [read, write] = mador({ count: 1 }); read(".counter", ctx => ctx.el.textContent = ctx.count); write(".increment", "click", ctx => ctx.count++); write(ctx => ctx.count = 0); ```
## Read
Dependencies are detected automatically when the read function is run during initiation.
```js read(".counter", ctx => ctx.el.textContent = `Count: ${ctx.count}`); ```
## Write
Immediate:
```js write(ctx => ctx.count++); ```
Event-triggered:
```js write(".increment", "click", ctx => ctx.count++); ```
Event writes expose `ctx.el` and `ctx.event`.
It’s a very smart idea though, I like it.
Good learning experience but a very weird presentation.
Unsure why this comment from the author was flagged/dead but it certainly doesn’t seem to run afoul of HN guidelines.