Are there any established patterns for global settings/state for components?

StackOverflow https://stackoverflow.com/questions/23157397

  •  05-07-2023
  •  | 
  •  

문제

Currently, I've got a component something like this:

<polymer-element name="my-widget" constructor="MyWidget">
  <script>
    Polymer('my-widget', {});
    MyWidget.someGlobalConfigValue = 1234;
  </script>
</polymer-element>

Are there other approaches to this that I should consider?

(aside: It'd be neat if Polymer() returned the constructor, so I don't have to force a name)

도움이 되었습니까?

해결책

One pattern is to use a component for configuration: http://www.polymer-project.org/docs/polymer/polymer.html#global

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top