googlearchive / firebase-util

An experimental toolset for Firebase
http://firebase.github.io/firebase-util
MIT License
276 stars 67 forks source link

Angular 2 Pipes and NormalizedRef.toString() #81

Closed lf-alves closed 8 years ago

lf-alves commented 8 years ago

Ever since I watched Sara Robinson's talk at AngularConnect earlier this year I started using the pipes she used in her presentation to display data with ngFor.

However, it seems that this will only work if you pass in a valid firebase url and then pipe an event like child_added or value, for example.

My question is, when it comes to normalizing paths and then retrieving the merged url (like it's possible to do when you call NormalizeCollection and then call toString()), will it ever be possible to enable this kind of merged path be a valid url to use along with those pipes?

In her example, she had the following template:

*ng-for="#message of firebaseUrl | firebaseevent:'child_added'"> {{message.name}}: {{message.text}}

and firebaseUrl being:

this.firebaseUrl = "https://angular-connect.firebaseio.com/messages";

What I wanna ask is, what if I needed that firebaseUrl to be a product of a normalization?

normalizeSomething(masterRef, indexRef){ let normalizedRefUrl = new Firebase.util.NormalizedCollection([masterRef, "indexed"], [indexRef, "something"]).select( "indexed.$key", "something.field" ).ref().toString(); return normalizedRefUrl; }

Will we ever be able to use that pipe with that normalizedRefUrl? Or it's just a feature for normal firebase users who won't be using firebase-util?

katowulf commented 8 years ago

Hi Luis,

I'm pretty sure the only change you'd need to make here is to pass in the Firebase ref, rather than passing in a string. It looks like you'd need to either change this line to be private _fbRef:Object; or change NormalizedRef to extend Firebase--something we'd need to do anyway to make Firebase-util ES6 compliant.

☼, Kato

lf-alves commented 8 years ago

Alright, thanks Kato. I'll try that.

katowulf commented 8 years ago

Cheers. We'll be putting some time and energy into Angular2/Firebase in the new year. I'll get together with @davideast and @jeffbcross and make sure we consider this use case as well in our designs.