Open hsinyi opened 11 years ago
I'd agree with how you put it on the second sentence. Do you expect that the 'callschanged' event contain the call array (sequence)? It is expected to be a short array.
In Mozilla's design, callschanged event type is TelephonyEvent containing a nullable TelephonyCall object. In the case of notifying calls array is ready, the callschanged event isn't carrying a call. Having a simple notification in the case should be fine.
Learned from feedback from mozilla app developers, there needs a way to tell if the calls array is ready even the calls array is empty. Otherwise, how can they differentiate telephony.calls giving us an empty array because it's not ready from telephony.calls or giving us an empty array because there is no call?
The mozilla's solution is making use of the 'callschanged' event. We could just guarantee that every time app registers an oncallschanged listener, they are guaranteed to get a callback at some point. If the calls array has loaded then the app will get the event on the next tick. If the array hasn't loaded yet then the app will get the event as soon as it has.