rokubrightscript

Is it possible to extend a component that is derived from a ComponentLibrary?


Question

I'm working with Roku's SceneGraph framework and need to extend a component from my ComponentLibrary.

What I'm trying to achieve

I want to allow consumers of my library to extend components using SceneGraph's extend feature. For example, enabling them to create a CustomController (derived in the component library consumer) that extends my library's AbstractController (derived in the ComponentLibrary) component.

What I've tried

I attempted to extend the component by referencing the library name and component name:

<component name="CustomController" extends="ComponentLib:AbstractController">

This resulted in compile errors.


Solution

  • Unfortunately no, extending a component from a component library is not supported. This is because component libraries are loaded at runtime, whereas your app is compiled far sooner in the process. Think of the timing of events like this:

    1. Zip your app, upload it to a Roku device
    2. Roku compiles your app.
    3. Roku runs your app
    4. Your app downloads and registers a component library
    5. When the component library finishes loading, you can start using components from it

    So as you can see, the problem is you cannot get past step 2 when the components you need to extend are from step 5.