Passing object messages


show more Passing object messages provides you with in-depth training on Developer. Taught by Andy Olsen as part of the HTML5 Power Workshop show less
please wait ...

Passing object messages

Sometimes, when you're using web workers, you might want to pass a complex object from the main page into the worker in order to tell it what to do. And likewise, the web worker might want to pass back a complex object as the result. So, we're going to see how to do that in this lesson. The webpage is called Object echo.html and there were three bits of information that we want to pass in to the worker. There's an integer that indicates how many replies we want to get back, from the worker, so I'll type in a number such as 5. We can also specify the gap that we'd like to have between replies. So something like 2000 milliseconds, and when I click start worker, it posts a message to the worker.

And the message is an object, and the object contains three properties. The first property is a string such as this, hi from worker 1. The second property is an integer called num replies, and the third part is an integer called gap. So what I do, and we'll see...

Passing object messages
Video duration: 7m 30s 3h 9m Intermediate

Viewers:

Passing object messages provides you with in-depth training on Developer. Taught by Andy Olsen as part of the HTML5 Power Workshop

Subjects:
Developer Web video2brain
Software:
HTML
Author:
please wait ...