divshot / pvc-globals

A Polymer element for keeping track of document-global information.
MIT License
7 stars 1 forks source link

How do I use it? #1

Open kristianmandrup opened 9 years ago

kristianmandrup commented 9 years ago

I'm trying to DRY up the Q&A Firebase demo app using globals to configure the firebase endpoint. Not sure how to use the namespace and set a single global key value?

PS: Components page referenced in README is 404.

<pvc-globals namespace="firebase.endpoint" values="https://fire-people.firebaseio.com"></pvc-globals>
<firebase-login id="baseLogin" user="{{user}}" statusKnown="{{statusKnown}}" location="{{globals.firebase.endpoint}}" provider="github" on-login="{{onLogin}}" on-error="{{onLoginError}}"></firebase-login>

I would like to create a firebase-model element sth like this

<firebase-model id=“answers” endpoint=“{{globals.firebase.endpoint}}” path="questions/{{questionId}}/answers/{{id}}” data=“{{answer}}”

Perhaps you can help me to find a nice way to do this for a win/win ;)

<polymer-element name="firebase-model" attributes="endpoint path" extends="firebase-element">  
  <script>
    (function () {
      'use strict';

      Polymer({
        observe: function() {
          endpoint: 'updateLocation',
          path: 'updateLocation'
        }

        // we can only set the list atribute when ref has changed (ie. not null)
        updateLocation: function() {
          this.location = [this.endpoint, this.path].join('/');
        }
      });

    })();
  </script>
</polymer-element>