A teammate and I have been building an application in Aurelia for the last four months, and he and I have been creating and using components in these two different ways. I want to have some consistency and change everything over to one of the two styles, but I don't know which one is preferred or more suitable for our needs.
I chose to use <compose>
because to me it feels cleaner and suits every need I have encountered, but if using the custom element is objectively better I want to switch to that.
For example:
(his-way view-model:)
import { bindable, bindingMode } from 'aurelia-framework';
export class HisWay {
@bindable({ defaultBindingMode: bindingMode.twoWay }) data;
}
(his-way view:)
<require from="./his-way"></require>
<his-way data.two-way="myModel" containerless></project-name>
(my-way view-model:)
export class MyWay {
activate(model) {
this.model = model;
}
}
(my-way view:)
<compose view-model="./my-way" model.bind="myModel" containerless></compose>
Do I need to change over, and if not, what are some reasons I can use to persuade him to using the same style that I have been using?
<his-way>
instead of<compose view-model="./my-way">
. – Mutatecontainerless
everywhere. I can't say I agree with the sentiment. – Mikimikihisa<compose>
you can render a component that will be defined at run time. For instance,<compose view-model.bind="someViewModel" view.bind="someView"></compose>
. Another advantage is that with<compose>
you can reuse views and view-models. You can use the same view for 2 different components – Refugee<compose>
in this way already. Thanks! – Mikimikihisa