polymer-dart / polymerize

Other
29 stars 3 forks source link

How do I override a method? #5

Closed ErikGrimes closed 7 years ago

ErikGrimes commented 7 years ago

I've tried:

namespace: Polymer
package-name:  polymer_elements
externals:
 "Polymer.IronFormElementBehavior": "package:polymer_elements/iron_form_element_behavior.dart"
 "Polymer.Templatizer": "package:polymer_element/polymer_element.dart"
 "Templatizer": "package:polymer_element/polymer_element.dart"
components:
 - name :    "iron-validator-behavior"
   ref : "PolymerElements/iron-validator-behavior#2.0-preview"
   overrides:
     IronValidatorBehavior:
       validate: "bool validate(dynamic values);"
resolutions:
  "polymer": "2.0.0-rc.1"
dam0vm3nt commented 7 years ago

This will work :

namespace: Polymer
package-name:  polymer_elements
externals:
 "Polymer.IronFormElementBehavior": "package:polymer_elements/iron_form_element_behavior.dart"
 "Polymer.Templatizer": "package:polymer_element/polymer_element.dart"
 "Templatizer": "package:polymer_element/polymer_element.dart"
components:
 - name :    "iron-validator-behavior"
   ref : "PolymerElements/iron-validator-behavior#2.0-preview"
   overrides:
     Polymer.IronValidatorBehavior:
       validate: 
         - "  extern bool validate(dynamic values);"
resolutions:
  "polymer": "2.0.0-rc.1"

Please note that you have to use extern keyword. And this will work only if you don't change the method name. To enable more generic mapping we should wait for extensions method feature to be added to dart (https://github.com/dart-lang/sdk/issues/24779) please vote it!

dam0vm3nt commented 7 years ago

BTW : at the moment there is a polymer issue that make it impossible to use native old style (v.1) behavior with 2.0 component. see here for info

ErikGrimes commented 7 years ago

What sort of problems does that cause for polymer-dart users? I read the associated issues, but I'm not sure I understand the implications.

On Tue, Mar 7, 2017 at 2:09 PM Vittorio Ballestra notifications@github.com wrote:

BTW : at the moment there is a polymer issue that make it impossible to use native old style (v.1) behavior with 2.0 component. see here https://github.com/Polymer/polymer/issues/4378 for info

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/polymer-dart/polymerize/issues/5#issuecomment-284843715, or mute the thread https://github.com/notifications/unsubscribe-auth/ABdljjeDulh5KDuVs60_PAWtOxJkz4hPks5rjblwgaJpZM4MV5Bg .

dam0vm3nt commented 7 years ago

Actually it turns out to be a polymer-redux problem. When mixin a behavior only the properties of the latest behavior that was mixed will be used by redux.

If you don't use redux there should be no problems then, but I hope polymer-redux people will fix it.

dam0vm3nt commented 7 years ago

type : extern -> external