I tried looking this up but I couldn’t find anything.
I have to different firebase objects:
1. speechList has:
1.1 $asArray of objects, each of which has:
1.1.3 .key (this is the foreign key to the full speech object)
2. currentSpeech. An $asObject() which has
So speechList has many items in it, one of them has a reference to currentSpeech.
Both objects are shown on the page.
I want to keep currentSpeech.title and speechList[id].title in sync.
Is there a best way to do this?
Here is the current way I’m doing it (which seems bloated)
0. Create a new object called activeSpeechListItem, this will be the object from speechList that has a reference to currentSpeech
1. Create isCurrentSpeechLoaded and set to false
2. Create isSpeechListLoaded and set to false
3. When currentSpeech is loaded (which could happen after 4):
3.1 Set isCurrentSpeechLoaded to true.
3.1 Attempt to set activeSpeechListItem. Will not if isSpeechListLoaded is still false.
4. When speechList is loaded (which may happen before 3):
4.1 Set isSpeechListLoaded to true.
3.1 Attempt to set activeSpeechListItem.Will not if isCurrentSpeechLoaded is still false.
0. Everytime currentSpeech.title input field has a change event:
1. If the above process has finished and everything is loaded:
1.1 Update aciteSpeechListItem.title from currentSpeech.title
1.2 $save object
2. Else do nothing.
It seems to work, but it’s clogged up my controller and feels heavy. Ideally, I was hoping there was some type of built in function that could do it all for me :)
The full code is here: https://github.com/MakeAwesomeStuff/makeawesomespeeches/blob/844d42c18c47e71d0fccbe18372006171a299116/app/scripts/controllers/account.js
You received this message because you are subscribed to the Google Groups "Firebase + AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to email@example.com.
To post to this group, send email to firstname.lastname@example.org.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-angular/1423637442917.01aaeb4d%40Nodemailer.
For more options, visit https://groups.google.com/d/optout.