summaryrefslogtreecommitdiff
path: root/node_modules/webworker-threads/examples/quickIntro_evented_childThreadCode.js
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/webworker-threads/examples/quickIntro_evented_childThreadCode.js')
-rw-r--r--node_modules/webworker-threads/examples/quickIntro_evented_childThreadCode.js7
1 files changed, 7 insertions, 0 deletions
diff --git a/node_modules/webworker-threads/examples/quickIntro_evented_childThreadCode.js b/node_modules/webworker-threads/examples/quickIntro_evented_childThreadCode.js
new file mode 100644
index 0000000..ba31205
--- /dev/null
+++ b/node_modules/webworker-threads/examples/quickIntro_evented_childThreadCode.js
@@ -0,0 +1,7 @@
+function fibo (n) {
+ return n > 1 ? fibo(n - 1) + fibo(n - 2) : 1;
+}
+
+thread.on('giveMeTheFibo', function onGiveMeTheFibo (data) {
+ this.emit('theFiboIs', fibo(+data)); //Emits 'theFiboIs' in the parent/main thread.
+}); \ No newline at end of file