What guidance can we give people about ReSpec and adding event listeners

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

What guidance can we give people about ReSpec and adding event listeners

Shane McCarron
I ran into an interesting problem today. Even if ReSpec is the first script in a sequence, there is a risk that subsequent scripts will load and execute first.  So if, for example, I have code like:

respecEvents.sub('end', function(message) { });

It can throw an error because respecEvents is not yet defined.

What guidance can we give spec authors to avoid this sort of race condition?

--
Shane McCarron
Managing Director, Applied Testing and Technology, Inc.
Reply | Threaded
Open this post in threaded view
|

Re: What guidance can we give people about ReSpec and adding event listeners

Robin Berjon-6
On 10/04/2015 19:31 , Shane McCarron wrote:
> I ran into an interesting problem today. Even if ReSpec is the first
> script in a sequence, there is a risk that subsequent scripts will load
> and execute first.

Are you loading ReSpec with async?

--
Robin Berjon - http://berjon.com/ - @robinberjon

Reply | Threaded
Open this post in threaded view
|

Re: What guidance can we give people about ReSpec and adding event listeners

Tobie Langel-3

On Sat, Apr 11, 2015 at 8:35 PM, Robin Berjon <[hidden email]> wrote:
On 10/04/2015 19:31 , Shane McCarron wrote:
I ran into an interesting problem today. Even if ReSpec is the first
script in a sequence, there is a risk that subsequent scripts will load
and execute first.

Are you loading ReSpec with async?

--
Robin Berjon - http://berjon.com/ - @robinberjon


Reply | Threaded
Open this post in threaded view
|

Re: What guidance can we give people about ReSpec and adding event listeners

Shane McCarron
In reply to this post by Robin Berjon-6
Sometimes.  But even if I do not. if respec is in "development mode" where it is not compiled into a single file, all of the attendant requires and JS loads can take some time.  When testing interactions between ReSpec and local scripts it is usually helpful to use the source form of ReSpec instead of the compiled form.

On Sat, Apr 11, 2015 at 1:35 PM, Robin Berjon <[hidden email]> wrote:
On 10/04/2015 19:31 , Shane McCarron wrote:
I ran into an interesting problem today. Even if ReSpec is the first
script in a sequence, there is a risk that subsequent scripts will load
and execute first.

Are you loading ReSpec with async?

--
Robin Berjon - http://berjon.com/ - @robinberjon



--
Shane McCarron
Managing Director, Applied Testing and Technology, Inc.