firebase の 3 レベル構造にいくつかのデータがあります。Polymerfire の firebase-query 要素を使用して、簡単にデータを取得し、必要なものを抽出できます。しかし、第 3 層のデータを変更しても、Polymer のデータ バインディング機能を利用しているため、iron-list にそれが反映されると期待しても何も起こりません。
クエリパスがデータを変更している直接のレベルであり、すべて正常に動作する場合に、正常に動作する他のインスタンスがあります。
このスレッドに出くわしました。firebase -query にこの問題があるようです。解決されているかどうかは疑問ですが、そうでない場合は、変更のみを取得する簡単な方法を教えていただければ幸いです。現在、リンクに示されているパスを使用していますが、かなり面倒です。ありがとう。
「読みやすくするために関係のないものは削除しました」
ここに私のデータ構造があります:
{
"ky42sqEauWW0MMqEJaidCAI7Fcl1" : {
"499248079923499248138779" : {
"data" : "someValue", //this is what I need to be notified about when it changes
},
"499248079923499248138755" : {
"data" : "someOtherValue",
}
}
}
ここで、データを iron-list にバインドします。
<!all the imports and headers ... >
<head>
</head>
<body>
<dom-module id="test-page">
<template>
<style>
</style>
<firebase-query
id="myQuery"
app-name="test"
path="/myPath/here"
log=true
data="{{myData}}">
</firebase-query>
<app-header-layout has-scrolling-region style="top: 10px; width: 100%; min-height: 400px;">
<iron-list id="ironList" items="[[myData]]" as="myItem">
<template>
<some stuff goes here that need to change when data is updated after change>
</template>
</iron-list>
</app-header-layout>
<script>
HTMLImports.whenReady(function() {
Polymer({
is: 'test-page',
properties: {
items: {
type: Array
},
user: String,
uid: String,
myData: {
type: Array,
notify: true,
observer: '_itemsChanged',
},
},
//got this from the link above
observers: [
'_itemsChange(schedData.*)'
],
_itemsChange: function(schedData) {
console.log('my items changed: ', schedData);
},
//the polymerfire gives something like this as an example but
//I can't get it to actually work without getting my hands dirty trying to extract only the changed data
_itemsChanged: function(newData, oldData) {
console.log("old new data" , newData , oldData);
},
});
});
</script>
</dom-module>
<setting-page></setting-page>
</body>
</html>