Conversation
|
The overall API looks good to me. We might consider a double underscore to further make it look different from normal component name hyphens (like OOCSS namespaces). |
|
I agree with @ngokevin having double underscore maybe looks uglier but it will make it easier to differentiate between normal components and multiple instances |
|
I'm trying this PR on the editor. Please share what you think about the way to show this feature: aframevr/aframe-inspector#72 /cc @ngokevin @dmarcos |
|
It fails just on flushToDOM: function () {
var attrValue = this.attrValue;
if (!attrValue) { return; }
HTMLElement.prototype.setAttribute.call(this.el, this.name, this.stringify(attrValue));
},Should be something like: flushToDOM: function () {
var attrValue = this.attrValue;
if (!attrValue) { return; }
var nameId = this.name + (this.id ? '_' + this.id : '');
HTMLElement.prototype.setAttribute.call(this.el, nameId, this.stringify(attrValue));
},I'm thinking also about el.emit('componentchanged', {
name: this.name,
newData: this.getData(),
oldData: oldData
});With the current implementation it will emit just |
0c476eb to
0506450
Compare
src/components/sound.js
Outdated
| var id = this.id; | ||
| this.listener = null; | ||
| this.sound = null; | ||
| this.object3DName = id ? 'sound-' + id : 'sound'; |
There was a problem hiding this comment.
why don't we use here the same style as the component's name? sound__
0506450 to
7dcea81
Compare
| value: function (name, data, isDependency) { | ||
| var component; | ||
| var componentInfo = name.split('__'); | ||
| var id = componentInfo[1]; |
There was a problem hiding this comment.
Won't this error? 'geometry'.split('__')[1]
There was a problem hiding this comment.
Name componentId might help differentiate from just HTML ID.
There was a problem hiding this comment.
it will return undefined, we could leave it that way or do something like componentInfo[1] || null. In any case it should works as expected on the rest of the code where the full name is built using: componentName = id ? component + '__' + id : component and both undefined or null will return false.
There was a problem hiding this comment.
No it just returns undefined
There was a problem hiding this comment.
umm, maybe instanceId ? and the componentId could be the whole name componentName__instanceId?
There was a problem hiding this comment.
I think the id has to be still easily accessible. Each component is going to handle multiplicity in a different way and it's nice to have access to the id directly without having to parse any string. I can add this.name, this.attrName, this.id to the component.
|
|
||
| if (name.indexOf('__') !== -1) { | ||
| throw new Error('The component name `' + name + '` is not allowed. ' + | ||
| 'The sequence __ (double underscore) is reserved and cannot be used ' + |
There was a problem hiding this comment.
Would update to The sequence__(double underscore) is reserved for multiple components of the same type. since the "cannot be used" is sort of restating the first sentence


Description:
It allows defining multiple component of a specific kind by appending an id to the component name followed by a
__character. e.g:Components have to opt into multiplicity otherwise an error is thrown.
This PR depends on #1565
Needs feedback from @fernandojsg