Comments (2)
This is not an issue with closure variables, I think maybe just a slight misunderstanding of how Karax works.
Here's what is happening from Karax's point of view, when you use the code in case 2:
- It's told that whenever something changes, it should call
createDom
to get the latest vdom tree (you tell it this with thesetRenderer
call) - It calls
createDom
to get the initial vdom tree to render.createDom
initializeslines
as an empty seq, then returns a tree of VNodes representing the desired state of the dom. This initial tree does not include any text fromlines
, as it is empty - It renders that initial tree to the page, in doing so attaches an onclick handler to the button element. This handler is wrapped so that it includes a call to
redraw()
- You click the button, firing the onclick event handler
- The event handler adds a string to the
lines
seq, then callsredraw()
- To redraw the app, Karax calls
createDom
to get the latest updated version of the vdom tree createDom
initializeslines
as an empty seq, then returns a tree of vnodes. This tree again does not include any text fromlines
, as it is empty- Karax diffs the two trees, but does not find any changes as they are the same, so nothing happens
This is not a bug in Karax, so there is no error message expected
from karax.
thanks for your nice & complete explanation,
I was misunderstood,
from karax.
Related Issues (20)
- Delay in redrawing dom HOT 6
- Broken functionalities when karax used with grammarly or languagetool (and possibly other extensions) HOT 8
- How to run a function on onclick event in a button? HOT 4
- Boolean Attributes in DSL HOT 6
- Event example does not work HOT 8
- Release 1.2.3 HOT 5
- view doesn't update when changing state in setInterval HOT 3
- IndexDefect on array HOT 3
- Karax input text becoming null HOT 1
- Async karax? HOT 3
- Empty content editable raises an error HOT 1
- How to attach and detach a custom a `Node` to the karax dom? HOT 1
- Karax does not update event handlers HOT 4
- stack size exceeded error on js target HOT 1
- `verbitam` content is appended every time it changes HOT 1
- runtime error on redraw in `removeAllEventHandlers` proc HOT 2
- SVG rendering HOT 2
- 1.3.2 has a tag and release, but karax.nimble version still 1.3.1 HOT 1
- inline closures in loop all capture the last instance for onclick HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from karax.