Defining a global filter/transformer in Polymer.dart

那年仲夏 提交于 2019-12-05 06:53:47

I'm not aware of a global way to define a transformer, but I use the following workaround: I have a class containing my global transformers, that are included into my custom elements using a mixin. Put it into a library that you include into every element. My global transformer mixin:

abstract class GlobalTransformersMixin extends Object implements Observable {
  @observable
  final Transformer asInteger = new _StringToInt();
  //...
}

Using it in an custom element:

@CustomTag('my-elment')
class MyElement extends PolymerElement with GlobalTransformersMixin {
    //...
}
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!