GithubHelp home page GithubHelp logo

Comments (4)

droidkid avatar droidkid commented on April 20, 2024

Hey, was wondering why InternalNode implements both ComponentLayout and ComponentLayout.Builder. Is there any specific reason for this?

Would it make more sense to have one of those classes implemented as a inner/nested class of InternalNode?

If ComponentLayout was a implemented as a inner class, InternalNode.build() could return a new instance of the inner class. The returned object would be immutable. Or similarly, if ComponentLayout.Builder was implemented as a inner class, you get your classic Builder pattern.

Your thoughts? Thanks!

from litho.

emilsjolander avatar emilsjolander commented on April 20, 2024

As long as we pool and recycle the builder as well as the bested object I think that would be fine. "Locking" the object when it is built is probably much easier to implement though and serves the same purpose as the InternalNode is not a public class.

from litho.

droidkid avatar droidkid commented on April 20, 2024

Having a new inner class might be troublesome as ComponentLayout is casted to InternalNode ComponentContext,LayoutState and I'm guessing in a few more places.

Once InternalNode.build() is called, only mutate methods part of ComponentLayout.Builder interface methods should throw an exception right?

For example, in ComponentContext.createLayout, appendComponent() is called on an InternalNode (which had build() called on it). Since appendComponent is not part of ComponentLayout.Builder(), we allow it and don't throw exception.

from litho.

pavlospt avatar pavlospt commented on April 20, 2024

Can be closed since the referencing issue was also closed!

from litho.

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.