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

Commit e563c0c

Browse files
author
Scott J. Miles
committed
metadata
1 parent 7fd6f17 commit e563c0c

File tree

2 files changed

+75
-61
lines changed

2 files changed

+75
-61
lines changed

bower.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"authors": [
55
"Scott J. Miles <[email protected]>"
66
],
7-
"description": "Element interface to FireBase Web API",
7+
"description": "Element wrapper for the FireBase Web API",
88
"keywords": [
99
"Polymer",
1010
"FireBase"

fire-base.html

+74-60
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,75 @@
1-
<link rel="import" href="../polymer/polymer.html">
2-
3-
<script src='../firebase/firebase.js'></script>
4-
5-
<polymer-element name="fire-base" attributes="location list">
6-
7-
<script>
8-
9-
Polymer('fire-base', {
10-
ready: function() {
11-
},
12-
13-
locationChanged: function() {
14-
var dataRef = new Firebase(this.location);
15-
16-
var job, list = [];
17-
18-
// TODO(sjmiles): this is a really bad way of doing this
19-
dataRef.on('child_added', function(snapshot) {
20-
list.push(snapshot.val());
21-
job = this.job(job, function() {
22-
this.fire('items-added');
23-
});
24-
}, this);
25-
26-
this.list = list;
27-
this.dataRef = dataRef;
28-
},
29-
30-
push: function(item) {
31-
this.dataRef.push(item);
32-
},
33-
34-
remove: function(item) {
35-
// TODO(sjmiles): this is a really bad way of doing this
36-
this.dataRef.once('value', function(snap) {
37-
snap.forEach(function(snap) {
38-
var rec = snap.val();
39-
for (var n in rec) {
40-
if (item[n] !== rec[n]) {
41-
return false;
42-
}
43-
}
44-
snap.ref().remove();
45-
this._removeFromList(item);
46-
return true;
47-
}.bind(this));
48-
}, this);
49-
},
50-
51-
_removeFromList: function(item) {
52-
var index = this.list.indexOf(item);
53-
if (index >= 0) {
54-
this.list.splice(index, 1);
55-
}
56-
}
57-
});
58-
59-
</script>
60-
1+
<link rel="import" href="../polymer/polymer.html">
2+
3+
<!-- depends on `firebase` components -->
4+
<script src='../firebase/firebase.js'></script>
5+
6+
<!--
7+
/**
8+
*
9+
* Element wrapper for the FireBase Web API.
10+
*
11+
* @class fire-base
12+
* @blurb Element wrapper for the FireBase Web API
13+
* @status alpha
14+
* @snap snap.png
15+
*
16+
*/
17+
-->
18+
19+
<polymer-element name="fire-base" attributes="location list">
20+
21+
<script>
22+
23+
Polymer('fire-base', {
24+
ready: function() {
25+
},
26+
27+
locationChanged: function() {
28+
var dataRef = new Firebase(this.location);
29+
30+
var job, list = [];
31+
32+
// TODO(sjmiles): this is a really bad way of doing this
33+
dataRef.on('child_added', function(snapshot) {
34+
list.push(snapshot.val());
35+
job = this.job(job, function() {
36+
this.fire('items-added');
37+
});
38+
}, this);
39+
40+
this.list = list;
41+
this.dataRef = dataRef;
42+
},
43+
44+
push: function(item) {
45+
this.dataRef.push(item);
46+
},
47+
48+
remove: function(item) {
49+
// TODO(sjmiles): this is a really bad way of doing this
50+
this.dataRef.once('value', function(snap) {
51+
snap.forEach(function(snap) {
52+
var rec = snap.val();
53+
for (var n in rec) {
54+
if (item[n] !== rec[n]) {
55+
return false;
56+
}
57+
}
58+
snap.ref().remove();
59+
this._removeFromList(item);
60+
return true;
61+
}.bind(this));
62+
}, this);
63+
},
64+
65+
_removeFromList: function(item) {
66+
var index = this.list.indexOf(item);
67+
if (index >= 0) {
68+
this.list.splice(index, 1);
69+
}
70+
}
71+
});
72+
73+
</script>
74+
6175
</polymer-element>

0 commit comments

Comments
 (0)