Closed koresar closed 7 years ago
After trying it out I found that the simplest and the most universal API would be this:
const HaveComposer = stampit.composers(function ({stamp, composables}) {
console.log('Resulting stamp:', stamp);
console.log('Was made of composables:', composables);
});
The implementation will still be specification compatible. The "composers" will be attached to the deepConfiguration
as the .composers
array. It will be deduped just like initializers array is.
The provided composers will be invoked immediately after being passed to the compose()
:
stampit.compose(AnyStamp, {composers({stamp, composables}) {
assert(composables[0] === AnyStamp);
assert(typeof composables[1] === 'object');
}});
Can you perhaps provide some real use case scenario? I still have a hard time to realize what this is good for actually. Even after rereading proposal couple times :) Consider me as the outside user on this and if there will be big barrier to understand this, not many people is actually going to use it.
Edit: My understanding is surely limited by fact that I had no need for infection just yet.
Providing the use case scenarios as a Fun with Stamps. Episode 11. Interfering composition https://medium.com/@koresar/fun-with-stamps-episode-11-interfering-composition-7abc44ac1f99 /cc @FredyC @amelon
Done