aurajs / aura

A scalable, event-driven JavaScript architecture for developing component-based applications.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Is `options.ref != options._ref` intentional?

mattlubner opened this issue · comments

In AuraJS version 0.9.2, an Aura component's this.options.ref is non-unique across multiple instances of the same component, whereas this.options._ref is unique across multiple instances (it ends with +#).

Shouldn't both values be the same, or is this difference intentional?

I ask because the aura-todos example has a useful Aura extension aura-backbones.js which uses options.ref when it's expecting something unique like options._ref. This effectively creates a single Backbone View per component type instead of per component instance, which broke my app.

If the aforementioned behavior is intentional, maybe it should be reconsidered? It sure seems like a gotcha!

Btw, thanks for making AuraJS – it's doing a fantastic job at simplifying JS development for me!

Hey @mattlubner thanks !
The naming is not very clear, I agree we chould find better names for these attributes

  • this.options._ref if a unique identifier for the instance of the component
  • this.options.ref is the identifier of the component's "class" and the name of its module defined in requirejs

The aura-todos example uses this.options.ref to "cache" the Backbone.View "class" that will be used by the instances of the component.

Good to know! In light of this, I'm thinking my approach needs reconsideration.

For the curious, I have multiple instances of a general component (for dropdown menus) which are individualized by being created with different contents / attributes (this is in a non-single-page app, so that stuff is created server-side). As such, each component needs its own unique Backbone View. A shared Backbone View resulted in every dropdown menu appearing whenever any menu item was hovered over.

Looks like the entire menubar should be its own component. Not sure why I hadn't just done that to begin with!