Term 2 – Week 3

Working this week on User notification, more specifically relating to displaying a notification to the user in the event of an audio failure. This has been one of the more difficult tasks to complete thus far.

Initially a few days were used to research the best way to accomplish this task. The Notifications component already exists and so does a callback function used to set the audio status. The main issue I encountered with this problem was; how to get a status variable, set by an asynchronous callback function from the Phone API, to communicate with the component so that when the status changes to an error, it can be rendered in the Notifications component. After a fair amount of research and discussions with colleges, there were quite a few ways to go about this.

  • 1) Using a collection.
  • 2) Using Events.
  • 3) Saving status as a Meteor variable


The question then became, which of these methods would be most suitable to use.

Collections :

By setting up a client side collection:

let clientCollection = new Mongo.Collection(‘collectionName’);

This can then be used to store the status from the audio status callback function. Using a listener to affect the rendering of the Notifications component when the collection changes. This method was not did not seem like the best option, was considered to be something that may work as a last resort in the event no other alternative methods were available.

Meteor variable :

A variable can be added to meteor and then that variable watched in the notifications component. The following command would add the variable to meteor:

callServer(‘updateAudioStatus’, { status: audio.status });

At this point, a meteor method would need to be created, updating a flag on the user collection, then on the notification component. The biggest drawback here is having to put extra work on the server side when it may not be needed.

Events :

For the events solution, we simply define an event:

let audioFailed = new CustomEvent(‘bbb.webrtc.failed’, { status: ‘Failed’ });

To fire/set-off the event we simply run the following:


The missing piece is the event listener which is basically the function that gets run when the event if triggered:

window.addEventListener(‘event.name’, function(e) {

//do stuff when event happens

}, false);

I have decided to go with the Events approach because of the nature of my task. Further research is conducted to understand exactly what events are in javascript and how they are properly implemented, from both a functional and best practice perspective.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s