You have a couple of options.
1. This could be something the component could figure out internally at run
time
2. you create a shared <app-state> element that is declared/used inside
your component. See
https://www.polymer-project.org/0.5/docs/polymer/polymer.html#global in the
0.5 docs.
3. you pass around globals using bindings. We've been doing this for the IO
website this year, and it's working quite well. Think of it as dependency
injection:

<my-app config="[[config]]"></my-app>

Then inside you'd use the config:

<iron-ajax url="[[config.url]]">

The only downside of this last approach is that it tends to get tedious.
`config` needs to be passed down to every component (and sub component)
that needs the state object.

On Sat, Mar 5, 2016 at 8:15 AM Colin Cannon <[email protected]> wrote:

> In my polymer app, where should I store global values used throughout my
> app?  For instance I have a lot of child elements that use iron ajax to
> call my api.  When I am developing I want to call my local api, but in
> production I want to call my production api.
>
> <iron-ajax url="dev.example.com/api" ...></iron-ajax>
>
> vs
>
> <iron-ajax url="www.example.com/api" ...></iron-ajax>
>
> Is there a cool polymer way to store a global config file with application
> constants?
>
> Follow Polymer on Google+: plus.google.com/107187849809354688692
> ---
> You received this message because you are subscribed to the Google Groups
> "Polymer" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/polymer-dev/a9faa04c-8b6e-4219-ac4f-5bea73a6d4b1%40googlegroups.com
> <https://groups.google.com/d/msgid/polymer-dev/a9faa04c-8b6e-4219-ac4f-5bea73a6d4b1%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

Follow Polymer on Google+: plus.google.com/107187849809354688692
--- 
You received this message because you are subscribed to the Google Groups 
"Polymer" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/polymer-dev/CACGqRCD%3DeYkVKWKkTyksAbuM0BupkCP7-Y15QB6Z3q7BR5WKwg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to