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

WIP. Custom shadow resolution #18

Open
mikaelkaron opened this issue Feb 3, 2015 · 1 comment
Open

WIP. Custom shadow resolution #18

mikaelkaron opened this issue Feb 3, 2015 · 1 comment

Comments

@mikaelkaron
Copy link
Member

We'd like to add custom shadow resolution when composing two specs with overlapping properties but different values.

Imagine this composition:

var X = Factory({
  "one": function () { ... },
},
  "one": false
});

var x = X();
x.one === false; // true

This makes total sense as compositions are composed left-to-right, however if you don't explicitly understand how your composition looked (or if you compose on someone else's object) bad things will happen.

Imagine the following composition:

var X = Factory({
 "one": function () { ... }
});

var XY = Factory(X, {
 "two": function () { ... }
});

This all makes sense and you'll end up with one well arranged composition. But what happens if the author of X decides to add a two method? Well, we're already shadowing it in XY, so the final composition will have two from XY. This is most likely what the application developer expected, but is it what the author of X expected?

This ticket tracks a proposal to add something like an unhandledShadowResolution callback to Factory that by default throws, but allows the developer to implement logic to choose what value to compose for a given property.

@mikaelkaron
Copy link
Member Author

@troopjs/maintainers please take a look and comment.

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

No branches or pull requests

1 participant