added exists attribute, reflecting whether we have data at a given path#234
Conversation
…th. An "empty-result" event is fired by firebase-document or firebase-query to notify that the path does not hold any data.
|
Any new on this one ? |
|
@mbleigh FYI |
|
@christophe-g can you check it again as it has some conflicts with firebase-query |
tjmonsi
left a comment
There was a problem hiding this comment.
Why not use the exist() method to show that a value on the snapshot really exists given a path?
I could edit this PR and add the ready attribute as well in this PR if you want or you can do it. :)
|
@tjmonsi - thanks !
I am not sure which If you are referring to For instance, as we already have this (with __onFirebaseValue: function(snapshot) {
var value = snapshot.val();
if (value == null) {
value = this.zeroValue;
this.__needSetData = true;
}It is pretty natural to set
I would rather keep |
I think we can change this as I'm still trying to find time for this but I think I can squeeze this in today with |
|
@christophe-g @tjmonsi In my opinion, both
In short, |
That is alright - I am pretty stretched! |
|
@christophe-g gotyah. Will work on it in a bit |
|
I see the reasoning behind this, but there are few things I’d like to discuss:
|
|
@merlinnot - thanks for looking at this.
|
| /** | ||
| * the element is notified that the path does not hold any data (fired by firebase-document or firebase query) | ||
| * | ||
| * @event empty-result |
There was a problem hiding this comment.
This event is unnecessary. One can use on-exists-changed which Polymer fires by default.
|
|
||
| /** | ||
| * `exists` is set to `true` when the data actually exists for the specified path; `false` otherwise. | ||
| * When we are unable to determine whether data exists or not (e.g. first round trip to the server not yet performed) the value is `null` |
There was a problem hiding this comment.
Could you please split this comment into multiple lines so it's more readable without line wrapping? ❤️
| value = this.__snapshotToValue(snapshot); | ||
|
|
||
| this.__map[key] = value; | ||
| this._setExists(true); |
There was a problem hiding this comment.
This should be moved after an assignment of a value to the data property.
| var key = snapshot.key; | ||
|
|
||
| if (this.__initialLoadDone) { | ||
|
|
There was a problem hiding this comment.
We don't have to add a new line here.
| * the callback if the query changes | ||
| */ | ||
| query.on('value', this.__onFirebaseValue, this.__onError, this); | ||
| this._setExists(null); |
There was a problem hiding this comment.
This one can be moved immediately after query.offs
| this.syncToMemory(function() { | ||
| this.splice('data', this.__indexFromKey(key), 1); | ||
| }); | ||
| if (this.data.length === 0) { |
There was a problem hiding this comment.
Hm... what if data is changed in some property effect? Don't you think we should get the length of data before calling this.splice?
There was a problem hiding this comment.
We are just assessing whether we have data or not. Sounds correct to me,
Could you please add some basic tests and resolve conflicts? Just a few test 😀 😃 @tjmonsi what about |
|
@tjmonsi @merlinnot - ready for review |
|
@merlinnot - any news on this ?
There are even tests ! |
|
@christophe-g I've seen all the work you've done and I'm really happy to see progress on this, but I'm not an owner of this repository and even if I would I'd like to wait for more people to take a look on this. Unfortunately, it's kinda hard to reach any of the owners lately, I don't really know why. We have to wait for @tjmonsi or @mbleigh to have some time to take a look at this. I've even tried to tweet the Firebase team but got no response. |
Replace and close #177.
Follows #33 discussion.
An "empty-result" event is fired by firebase-document or firebase-query to notify that the path does not hold any data.