Thanks Eric.  On the IO website where do you store global data specific to 
dev/prod?  For instance in my case my ajax calls will go to one url in dev 
and another in production.  Does your Polymer code store both sets of urls 
and other data and then Polymer checks the URL and then decides to use dev 
or prod data?

Right now I do use databinding so my app data is not spread out in all my 
components, but it is all still in my most parent component.  It would be 
nice to get it out of there.  I would go with option #2, but I think it 
would have to be a part of my code base (repo and webroot).

I am coming from a world where I did most of my dev with PHP and jQuery. 
 With PHP doing most of the work and rendering the pages I could keep an 
config file outside my webroot and outside my code repo and just have PHP 
include the file, which was mostly a bunch of defines.

On Saturday, March 5, 2016 at 10:14:11 AM UTC-8, Eric Bidelman wrote:
>
> 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] 
> <javascript:>> 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] <javascript:>.
>> 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/1b0ef7c0-b49b-47df-9613-e96c350bf59a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to