Giter Site home page Giter Site logo

Comments (4)

ncannasse avatar ncannasse commented on August 15, 2024

You're right that @:uiComp is mostly optional now. But it might still be used I think since you can customize the way the components names are resolved into classes by using domkit.Macros.registerComponentsPath at --init time

from domkit.

tobil4sk avatar tobil4sk commented on August 15, 2024

What I don't understand here is why there is an error in the sample above. The documentation states: "Components are resolved by name by adding Comp to the capitalized component name". The xml tag is <something />, and so according to this rule, by default it should look for SomethingComp. The class exists and from the error message, it clearly was able to locate the correct class: SomethingComp does not define component something.

Even if the component is in components.SomethingComp, and that path is registered using components.$Comp, it still fails unless SomethingComp is marked with @:uiComp("something"). If the path components.$Comp is registered, why does components.SomethingComp need to be marked explicitly as "something" if that's the class to which <something /> is meant to resolve to anyway, given it's a registered path to look for components in?

from domkit.

ncannasse avatar ncannasse commented on August 15, 2024

Yeah that's something I didn't deal with. In our games now we're using ui.comp.$ as path so we have exact ClassName == comp-name. I guess when there's no @:uiComp we should try to reverse the class resolution to see if we can find a valid component name before using directly the class name.

from domkit.

tobil4sk avatar tobil4sk commented on August 15, 2024

Hm, I see. I guess for now to avoid confusion it would be best to rewrite the documentation to suggest a similar setup (i.e. custom registration path with matching class and component names). I tried to have a look at the macros myself, and it seems to me like it would be difficult to change this behaviour without completely rewriting the component resolution system.

If the the class name is kept the same as the component name, i.e. "Something", (in the same package and without registerComponentsPath) gives a slightly different error: Could not load component 'something'.

I added a trace(RESOLVED_COMPONENTS); right before this line:

var c = RESOLVED_COMPONENTS.get(name);

It looks like the "something" component gets resolved, beause right before the error, it traces the RESOLVED_COMPONENTS map which contains something => {c: domkit.MetaComponent, path: null}. However, the build still fails with the Could not load component 'something' error. Maybe something to do with the null path?

Using the macro debugger, I've discovered that loadComponent("something", ...) gets called twice. The first time, it fails to load the component, and the second time it succeeds. So, it looks like the error comes from the first time the function is called.

from domkit.

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.