Skip to content
This repository has been archived by the owner on Mar 13, 2018. It is now read-only.

Please add firebase-list #29

Open
kristianmandrup opened this issue Dec 3, 2014 · 8 comments
Open

Please add firebase-list #29

kristianmandrup opened this issue Dec 3, 2014 · 8 comments

Comments

@kristianmandrup
Copy link

Should include an element that wraps this one https://github.com/katowulf/Firebase.getAsArray

Then we could avoid the keys hack and do filtering etc. directly in the template repeat :)

@kristianmandrup
Copy link
Author

Been playing around with this... discovered that to build on ref, you need to have it available as a Promise, otherwise if other elements bind to it, most likely it will be null and break.

@kristianmandrup
Copy link
Author

I think we should use a mixin approach for some basic/generic functionality to connect to the database which can be used across various firebase components.

http://pascalprecht.github.io/2014/07/14/inheritance-and-composition-with-polymer/

Got firebase-list working like this so far...

<link rel="import" href="../polymer/polymer.html">
<link rel="import" href="../firebase-element/firebase-element.html">
<script src="firebase-as-array.js"></script>
<polymer-element name="firebase-list" attributes="list" extends="firebase-element">
  <script>
    (function () {
      'use strict';

      Polymer({
        refChanged: function() {
          this.list = Firebase.getAsArray(this.ref);
        }
      });

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

To display the list of dinosaurs iterating a list

<body unresolved>
  <h1>Hello World</h1>
  <template is="auto-binding">
    <firebase-list location="https://owjo5nyx9dj.firebaseio-demo.com" list="{{list}}"></firebase-list>
    <h1>List</h1>
    {{list}}
    <template repeat="{{item in list}}">
      <li>{{item.name}}</li>
    </template>
</body>

Also works like this

    <firebase-element location="https://owjo5nyx9dj.firebaseio-demo.com" ref="{{ref}}"/>
    ...

    <firebase-list ref="{{ref}}" list="{{list}}"></firebase-list>    

@chuckh
Copy link
Contributor

chuckh commented Dec 4, 2014

+1. This would be very useful! Could use this with core-list as well as template repeat.

@kristianmandrup
Copy link
Author

I got it working locally and pushed my latest changes for PR. Try it out ;)
For some reason I get deprecation warnings from firebase.js however. name() is now key().
I fixed these warnings in the get-as-array javascript.

@kristianmandrup
Copy link
Author

You can try it out with this app... just needs to use firebase-list instead.

https://github.com/kristianmandrup/qa-firebase-app

From: https://divshot.com/blog/web-components/building-a-qa-system-with-polymer-and-firebase

@mbleigh
Copy link
Contributor

mbleigh commented Jan 24, 2015

See #38 for my take on lists.

@lucasfanning
Copy link

nice!

@mbleigh
Copy link
Contributor

mbleigh commented Feb 4, 2015

@lucasfanning @kristianmandrup my proposal was rejected for additional maintenance burden, so firebase-list now lives on its own at https://github.com/divshot/firebase-list -- hope you find it useful!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants