Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using components from child and sibling contexts #175

Open
ghost opened this issue Sep 11, 2015 · 0 comments
Open

Using components from child and sibling contexts #175

ghost opened this issue Sep 11, 2015 · 0 comments

Comments

@ghost
Copy link

ghost commented Sep 11, 2015

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants