0
votes

I have a polymer app that has a bound to my app's data which is its state. the state is pushed to all connected clients via firebase. Now I want to add "chat rooms". it's not chat but the analogy works. how do i create a chatroom and have it bound to my custom element's data property at runtime? i wanted to do something like:

<my-app><my-room chatId="{{currentChatId}}"></my-room></my-app>

and keep an array of chat room id's in my-app and the current chat room's data in my-room. so if my firebase data looked like {rooms : {room1: {chatId: 111...}} i wanted to the firebase-collection element in my-room to have its location property = "https://appname.firebase.io/{{chatId}}" and have the data property bound to a property in my-room. but since chatId will be null at creation time this solution doesn't work. I tried setting the firebase-collection location property in the observer for chatId at runtime but it didn't create any data when I changed the local data bound to the firebase-collection's data property. so my question is how do i have a firebase-collection element bound to data that doesn't exist at creation time?

2

2 Answers

0
votes

Thinking there may be other problems here, but a quick solution to the ? might be to use conditional templates - https://www.polymer-project.org/1.0/docs/devguide/templates.html#dom-if, i.e. you could wait to stamp the firebase-collection element until your chat id exists.

Again seems like there is potentially something else here that should be addressed but this might be a quick & dirty fix for you.

0
votes

I don't know what I was doing wrong before but setting the location property at runtime does work.