This repository was archived by the owner on Jul 30, 2018. It is now read-only.
This repository was archived by the owner on Jul 30, 2018. It is now read-only.
Terse API for Mixin #22
Closed
Description
The review of dojo/compose by the SitePen/dgrid (@maier49, @kfranqueiro, and @edhager) as highlighted that the mixin API should/could be significantly more terse, especially when dealing with complex type compositing. Ideally the API would work more like this:
const fooFactory = compose({
mixins: [ aFactory, BConstructorFunction, CClass, dObjectLiteral ],
aspect: {
before: { 'foo': aspectBeforeFunction },
around: { 'bar': aspectAroundFunction },
after: { 'baz': aspectAfterFunction }
},
init: initFunction
});
const foo = foo({ foo: 'bar' });
I expect the interface would need to be something like this:
interface ComposeAspectDefinition {
before?: { [ method: string ]: AspectBeforeMethod };
around?: { [ method: string ]: AspectAroundMethod };
after?: { [ method: string ]: AspectAfterMethod };
}
interface ComposeBaseFactoryDefinition {
aspect?: AspectDefinition;
init?: InitFunction | InitFunction[];
}
interface ComposeSingleFactoryDefinition<A extends Object, O> extends ComposeBaseFactoryDefinition {
mixins: ComposeFactory<A, O> | GenericClass<A, O> | A | [ComposeFactory<A, O> | GenericClass<A, O> | A];
}
interface ComposeTwoFactoryDefinition<A extends Object, B extends Object, O, P> extends ComposeBaseFactoryDefinition {
mixins: [ComposeFactory<A, O> | GenericClass<A, O> | A, ComposeFactory<B, P> | GenericClass<B, P> | B];
}
// etc...
interface Compose {
<A extends Object, O>(ComposeSingleFactoryDefinition<A, O>): ComposeFactory<A, O>;
<A extends Object, B extends Object, O, P>(ComposeTwoFactoryDefinition<A, B, O, P>): ComposeFactory<A & B, O & P>;
// etc...
}