Giter Site home page Giter Site logo

Question: nested components about choo HOT 6 CLOSED

choojs avatar choojs commented on May 13, 2024
Question: nested components

from choo.

Comments (6)

dy avatar dy commented on May 13, 2024 1

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.

yoshuawuyts avatar yoshuawuyts commented on May 13, 2024

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.

dy avatar dy commented on May 13, 2024

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.

dy avatar dy commented on May 13, 2024

Anyways looking forward to the new API!

from choo.

yoshuawuyts avatar yoshuawuyts commented on May 13, 2024

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.

yoshuawuyts avatar yoshuawuyts commented on May 13, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.