Comments (6)
Honestly I read the docs, all of that I knew before and I think that maybe I have conceptual misunderstanding. It is the case when DOM in some or other way contains more actual "model" than the app, therefore it can't be overwritten with any sort of view output.
Anyways I will wait for the new API with hopefully more examples.
Thank you for your work!
from choo.
haha, excellent timing on your question. Tbh we just solved this one a couple of hours ago haha, so we haven't had a chance to update the docs for this yet. To answer your paraphrased questions:
How should I setup and tear down widgets that contain state of their own? For example a Google Maps widget
Use Shama's on-load package for adding hooks to load
and unload
. Updating data can be done by diffing state
with oldState
passed in by views. This API is bound to change in v3 (#42) though.
Do updates in widgets conflict with the diffing algorithm?
The morphdom
diffing engine diffs real DOM trees with each other. This means that it doesn't matter what a DOM node is created with, the diffing algorithm can parse it. So as long as your widget returns valid nodes, choo
will merrily chug along
I hope this answers your questions. We're def working on making this smoother (see choojs/nanohtml#30), so expect to see more of this in the future - I hope this gets you where you want to be tho. Cheers!
from choo.
haha, funny - I used to write lifecycle package a couple of years ago - an analog of on-load.
But I don't understand yet - if side widgets have changed the real tree - what tree I should return from the view to avoid rewriting the real "good" tree with outdated one. Should views assemble tree from parts of real one and parts of "default" one?
from choo.
Anyways looking forward to the new API!
from choo.
use on-load
to provide hooks for setting up / tearing down, and then keep returning the tree with your widget mounted. The hooks will fire when it's added / removed from the DOM.
Consider reading through the yo-yo and morphdom docs more background info on how the diffing works. Hope this is helpful. Cheers!
from choo.
I'm assuming I've answered your question - closing this issue. If you've got further questions about this we're happy to reopen this, or consider opening a new issue. Thanks again for asking. Cheers! ✨
from choo.
Related Issues (20)
- Flicker on route change + window scroll in Safari HOT 2
- Redirects do not work HOT 3
- Page freeze in Safari when navigating using trackpad swipe HOT 3
- Is choo abandoned / no longer maintained? HOT 4
- HTML5 video autoplay in chrome HOT 9
- Running Router On a Specific Path with Hash Routing HOT 3
- Could not query selector id with hypen HOT 4
- Magic in the emitter callback? HOT 4
- v7.0.0 HOT 7
- Is it possible to use choojs with es import syntax? HOT 2
- Can I pass a rootNode to `nanohref`? HOT 5
- New feature: Async route support HOT 1
- [domain] ssl-cert expired HOT 6
- Experimenting with custom elements
- Route handler return value HOT 3
- Usage with http-server HOT 1
- What are the precise set of rewrite rules so that if a user specifies app.mount(<PATH>, component) they can retrieve that in the URL?
- Wrong return type for `mount`
- SSL_CTX_use_certificate:ee key too small
- Project abandoned? HOT 7
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 choo.