Skip to content

Using components from child and sibling contexts #175

@ghost

Description

There doesn't seem to be a way to use components in child and sibling contexts from within the spec. Once everything is wired you can of course use them with childContext.someComponent but you can't do that from the spec.

I'd like to propose this:

// child-spec.js
define({
    aComponent: {
        module: "someModule"
    }
});

// parent-spec.js 
define({
    childContext: {
        wire: "./child-spec"
    }
    anotherChildContext: {
        wire: "./another-child-spec"
    }
    aReference: {
        module: { $ref: "childContext.aComponent" }
    }
    // aReference resolves to aComponent in childContext
});

// another-child-spec.js
define({
    anotherReference: {
        module: { $ref: "childContext.aComponent" }
    }
    // anotherReference resolves to aComponent in childContext (a sibling context)
});

Currently you can only use top-level components from ancestor contexts. This includes any child contexts declared in the ancestor contexts; however, you can't directly use any components from them.

A good use for this would be namespacing. For example, if I had a bunch of controllers that I needed to use throughout my application, I could register them under a child context called controller. Then I could just use the components in controller in my spec with "controller.post" or "controller.user" etc. instead of "polluting" the parent namespace with lots of controller names.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions