Component

class Component.Incubator(component, parent, args)
Arguments
  • component (component()) – A component object

  • parent (Item()) – Parent item for newly created object

  • args (object()) – Initial properties to set in object

Returns

A deferred yielding an object

This is a constructor for a Deferred.Deferred() that will be resolved when object is totally incubated from Component. Component is created as a child of parent and has properties from args set as construction properties:

Item {
    id: me

    Property Component myRect: Rectangle {}

    function randomRect()
    {
        return new Incubator(myRect, me, {
            x: Math.random() * me.width,
            y: Math.random() * me.height,
            width: Math.random() * me.width,
            height: Math.random() * me.height,
            color: Qt.hsla(Math.random(), Math.random(), Math.random(), Math.random())
        });
    }
}
class Component.Loader(url)
Arguments
  • url (url()) – URL to load component from

Returns

A deferred yielding a Component

This is a constructor for a Deferred.Deferred() that will be resolved when url has been successfully loaded as a component:

Item {
    id: me

    // Creates an object from a given component URL and initial properties.
    function spawn(url, props)
    {
        return new ComponentLoader(url).then(function (component) {
            return new Incubator(component, me, props);
        });
    }
}
class Component.Factory(parent, lruSize)
Arguments
  • parent (Item()) – Parent item for newly created objects

  • lruSize (int()) – Count of components to keep in cache

Component Loader with a LRU cache

This object is a factory for components loaded from URLs. There is also a component cache that keeps references to loaded component objects to avoid another load between two incubations.

At most lruSize component references are kept.

Component.Factory.Component.Factory.get(url)
Arguments
  • url (url()) – A component URL

Returns

A deferred yielding a Component

Loads component from url and returns a Deferred that will be resolved once the component is loaded.