Coder Social home page Coder Social logo

Clear Data for Removed Widgets about kayak_ui HOT 4 CLOSED

MrGVSV avatar MrGVSV commented on June 12, 2024
Clear Data for Removed Widgets

from kayak_ui.

Comments (4)

StarArawn avatar StarArawn commented on June 12, 2024 1

Also just a good thing to know in general haha. So we keep the built widgets in current_widgets so that we don't have to re-build them, right?

Yep

from kayak_ui.

StarArawn avatar StarArawn commented on June 12, 2024

Using diffing (not sure if Re-enable Diffing #1 has been resolved or not), we could get a list of all the Change::Deleted nodes. Then we just iterate over them and manually remove the necessary data from KayakContext. This method is probably slower and more cumbersome, but probably much simpler to implement with adequate diffing.

Diffing isn't fixed yet. We need to wrap props in Binding<Prop> inside the widget proc macros. Once that's done we can ignore updating children. No need to diff either since the notify on the Binding does that for us. Once I'm back to working on kayak again I'll probably pick this task up first.

Utilize a crate like weak_table, to create the data HashMap and HashSet fields. Then add a trait method to Widget allowing it to return a reference to its Index (or maybe a custom wrapper struct). This way we could use a Weak as the key to automatically drop the stored data when the widget is removed. This way is a bit cleaner, but adds a dependency and requires changing a lot more code to integrate it. (Just did some quick testing and I guess widgets are dropped every render? I assume when rebuilding the tree? So maybe this whole idea wouldn't work anyways...)

We can use Change::Deleted with an iterator. We'll already have a Index to the widget there that we can use to delete all of its relevant data. Currently widget's are removed only from the tree.

from kayak_ui.

MrGVSV avatar MrGVSV commented on June 12, 2024

Diffing isn't fixed yet. We need to wrap props in Binding<Prop> inside the widget proc macros. Once that's done we can ignore updating children. No need to diff either since the notify on the Binding does that for us. Once I'm back to working on kayak again I'll probably pick this task up first.

Sounds good. And, yeah, just wanted to mark down the issue. There's no rush to come back 🙂

We can use Change::Deleted with an iterator. We'll already have a Index to the widget there that we can use to delete all of its relevant data. Currently widget's are removed only from the tree.

Yeah that's what I figured. That should be a fine solution, we'll just have to make sure we properly remove the data when they should be removed.

Also just a good thing to know in general haha. So we keep the built widgets in current_widgets so that we don't have to re-build them, right?

from kayak_ui.

StarArawn avatar StarArawn commented on June 12, 2024

Fixed with the rewrite! 👍 Please reopen if you feel as though this is still an issue.

from kayak_ui.

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.