@@ -9,13 +9,10 @@ brackets.getModule("worker/IndexingWorker")
99Phoenix houses a file indexing worker which caches all cacheable files of a project in memory.
1010This module can be used to communicate with the Index and extend it by attaching new js worker scripts to the
1111indexing worker as discussed below. Any extension that works on a large number of files should use the indexing
12- worker cache to free up the main thread of heavy file access. This is similar to
13- [ worker/ExtensionsWorker] ( ExtensionsWorker-API ) but with a full file index.
12+ worker cache to free up the main thread of heavy file access.
1413
15- * Extensions are advised to use [ worker/ExtensionsWorker] ( ExtensionsWorker-API ) if they do not use the file index and
16- just want to offload minor tasks.
1714* Extensions performing large compute tasks should create their own worker and may use easy util methods in
18- [ worker/WorkerComm] ( WorkerComm-API ) to communicate with the web worker.
15+ [ worker/WorkerComm] ( ../ WorkerComm) to communicate with the web worker.
1916
2017## Import
2118
@@ -43,7 +40,7 @@ IndexingWorker.loadScriptInWorker(workerPath);
4340Once the worker script is loaded with the above step:
4441* Phoenix can communicate with worker using the ` IndexingWorker ` reference in Phoenix.
4542* Worker can communicate with Phoenix with the global ` WorkerComm ` reference within the Indexing worker.
46- All utility methods in module [ worker/WorkerComm] ( WorkerComm-API ) can be used for worker communication.
43+ All utility methods in module [ worker/WorkerComm] ( ../ WorkerComm) can be used for worker communication.
4744
4845A global constant ` Phoenix.baseURL ` is available in the worker context to get the base url from which phoenix was
4946launched.
@@ -52,34 +49,37 @@ NB: You can use all util methods available in `worker/WorkerComm` as `IndexingWo
5249to communicate with the underlying worker thread.
5350
5451* [ worker/IndexingWorker] ( #module_worker/IndexingWorker )
55- * [ .WorkerComm-APIS ] ( #module_worker/IndexingWorker..WorkerComm-APIS )
52+ * [ .WorkerComm] ( #module_worker/IndexingWorker..WorkerComm )
5653 * [ "EVENT_CRAWL_STARTED"] ( #event_EVENT_CRAWL_STARTED )
5754 * [ "EVENT_CRAWL_PROGRESS"] ( #event_EVENT_CRAWL_PROGRESS )
5855 * [ "EVENT_CRAWL_COMPLETE"] ( #event_EVENT_CRAWL_COMPLETE )
5956
60- <a name =" module_worker/IndexingWorker..WorkerComm-APIS " ></a >
57+ <a name =" module_worker/IndexingWorker..WorkerComm " ></a >
6158
62- ### worker/IndexingWorker.WorkerComm-APIS
59+ ### worker/IndexingWorker.WorkerComm
6360To communicate between the IndexingWorker and Phoenix, the following methods are available:
6461` loadScriptInWorker ` , ` execPeer ` , ` setExecHandler ` , ` triggerPeer ` and other APIs described
6562in module ` worker/WorkerComm ` .
6663The above methods can be used with either ` IndexingWorker ` reference within Phoenix
6764or the global ` WorkerComm ` reference within the Indexing worker. (See example below.)
6865
69- See [ worker/WorkerComm] ( WorkerComm-API ) for detailed API docs.
66+ See [ worker/WorkerComm] ( ../WorkerComm ) for detailed API docs.
67+
68+ ``` js
69+ // To Execute a named function `extensionName.sayHello` in the worker from phoenix
7070
71- To Execute a named function ` extensionName.sayHello ` in the worker from phoenix
7271// in my_worker.js. It is a good practice to prefix your `[extensionName]`
7372// to exec handler to prevent name collisions with other extensions.
74- ``` js
73+
7574WorkerComm .setExecHandler (" extensionName.sayHello" , (arg )=> {
7675 console .log (" hello from worker " , arg); // prints "hello from worker phoenix"
7776 return " Hello Phoenix" ;
7877});
79- ```
78+
8079// In Phoenix/extension
8180let workerMessage = await IndexingWorker .execPeer (" extensionName.sayHello" , " phoenix" );
8281console .log (workerMessage); // prints "Hello Phoenix"
82+ ```
8383
8484** Kind** : inner property of [ <code >worker/IndexingWorker</code >] ( #module_worker/IndexingWorker )
8585<a name =" event_EVENT_CRAWL_STARTED " ></a >
0 commit comments