Add example to docs for LMLayer.asBlobURI().

This commit is contained in:
Eddie Antonio Santos 2018-11-27 14:32:37 -07:00
parent 6cc20cfd83
commit ac12cb6f28
No known key found for this signature in database
GPG key ID: DD411EA4D9509D87

View file

@ -61,6 +61,15 @@ class LMLayer {
* Converts the INSIDE of a function into a blob URI that can
* be passed as a valid URI for a Worker.
* @param fn Function whose body will be referenced by a URI.
*
* This function makes the following possible:
*
* let worker = new Worker(LMLayer.asBlobURI(function myWorkerCode () {
* postMessage('inside Web Worker')
* function onmessage(event) {
* // handle message inside Web Worker.
* }
* }));
*/
static asBlobURI(fn: Function): string {
let code = LMLayer.unwrap(fn);