Skip to content

Loading…

Wiring sub-contexts doesn't work inside a nested scope #123

Closed
AnAppAMonth opened this Issue · 10 comments

2 participants

@AnAppAMonth

Nested scopes are created by calling new Scope(this), the second parameter options isn't provided. This causes the createContext() method to not be available in the nested scope, and therefore using the wireFactory or calling pluginApi.createChild() fails.

@briancavalier
The Javascript Architectural Toolkit member

Directly using the undocumented APIs, like Scope, in lib is not currently supported. While we are moving in a direction that will allow more programmatic use, the APIs are still too fluid. Wire's primary API is the wire function, amd plugin, wire plugins, and the declarative spec format.

@AnAppAMonth

Try to wire this spec, and you encounter an error:

{
    myscope: {
        mycontext: {
            wire: {
                spec: 'myspec'
            }
        }
    }
}
@briancavalier
The Javascript Architectural Toolkit member

Have a look at #100 for more thoughts on programmatic APIs. Feel free to post your thoughts there! That's just the tip of the iceberg, and exposing more pieces, like Scope (or whatever Scope ends up being in v0.11), will probably be in the plan as well.

@briancavalier
The Javascript Architectural Toolkit member

Haha, yep, that breaks. Sorry I misunderstood your original post. Including test cases helps a lot. Thanks!

@briancavalier briancavalier reopened this
@briancavalier
The Javascript Architectural Toolkit member

@halfninety I think there is a fix in master now, in 2371067. Could you try it and let me know if that works for you?

@AnAppAMonth

Is the change in wirePlugin.js intended to fix a bug that causes components inside sub-contexts to be created multiple times? I just discovered the bug and located its source, and your change in wirePlugin.js fixes that.

Anyway, what's your purpose of mixing the sub-context's spec into the sub-context's instances dictionary? I figure you might remove this now.

@briancavalier
The Javascript Architectural Toolkit member

Is the change in wirePlugin.js intended to fix a bug that causes components inside sub-contexts to be created multiple times? I just discovered the bug and located its source, and your change in wirePlugin.js fixes that.

I've not noticed this problem, but it sounds pretty serious. I'll check on it. It could be related to the following bug, which I believe is fixed (I'm planning to release 0.10.1 today with the fix):

Anyway, what's your purpose of mixing the sub-context's spec into the sub-context's instances dictionary? I figure you might remove this now.

This was definitely a bug, and should be fixed in 2371067. It's also fixed in dev.

@briancavalier
The Javascript Architectural Toolkit member

components inside sub-contexts to be created multiple times

Do you have a test case for this one? I tried to reproduce it in an earlier version of dev (before the fix for the original problem in this issue) and wasn't able to. As you say, it does seem to work after the original fix as well.

Thanks!

@AnAppAMonth

I created a new issue #128. I almost finished writing it before I discovered you already fixed it..

@briancavalier
The Javascript Architectural Toolkit member

Awesome, I really appreciate the amazing level of detail in that issue!!! I'll followup there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.