Edmond Tamas
Edmond Tamas

Reputation: 3305

How to extend multiple mixins in the same Polymer element?

I am updating my Polymer App to 2.0, while trying to get familiar with the new concepts.

I would like to extend two mixins: DatastoreBehaviors and FacebookBehaviors in my Polymer element, but I can't figure out how to proceed:

element:

  class AppFeed extends DatastoreBehavior(Polymer.Element) {

      static get is() { return 'app-feed'; }

      ...


}

mixins 1:

const DatastoreBehaviors = (superClass) => class extends superClass {

    ...
}

mixins 2:

  const FacebookBehaviors = (superClass) => class extends superClass {

    ...
}

Upvotes: 1

Views: 1612

Answers (1)

a1626
a1626

Reputation: 2964

Multiple inheritance can be achieved in Polymer in following way

class AppFeed extends DatastoreBehavior(FacebookBehaviors(Polymer.Element)) { … }

which will create inheritance hierarchy like

AppFeed <= DatastoreBehavior(FacebookBehaviors(Polymer.Element)) <= 
FacebookBehaviors(Polymer.Element) <= Polymer.Element

You can also refer documentation.

Upvotes: 3

Related Questions