Skip to content

Commit

Permalink
Updated examples for new algth.
Browse files Browse the repository at this point in the history
  • Loading branch information
duart38 committed Aug 26, 2020
1 parent d102a3f commit 84a2cf4
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 11 deletions.
14 changes: 14 additions & 0 deletions examples/example_deno_worker.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import Thread from "../Thread.ts";
import Observe from "https://raw.githubusercontent.com/duart38/Observe/master/Observe.ts";

let tr = new Thread((e)=>{
let t = new Observe(e.data); // observable values
return t.getValue()
}, ["import Observe from 'https://raw.githubusercontent.com/duart38/Observe/master/Observe.bundle.js'"], true) // true enables deno

tr.postMessage("bing");

tr.onMessage((e)=>{
console.log(e);
});

20 changes: 9 additions & 11 deletions examples/example_importing.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
import Thread from "../Thread.ts";
import { CallMe } from '../test_import.js';
import {CallMe} from "../test_import.js"

function someFunction(e: MessageEvent) {
let tr = new Thread((e)=>{
CallMe();
return 1;
}
let thread = new Thread(someFunction, ["import { CallMe } from '../test_import.js'"]);
thread.onMessage((e) => {
console.log(`recived back from thread: ${e}`);
return "pong"
}, ['import {CallMe} from "./test_import.js"'])

tr.postMessage("ping");

tr.onMessage((e)=>{
console.log(e);
});
thread.postMessage(999);

setInterval(()=>{
thread.postMessage(999);
}, 4000)

0 comments on commit 84a2cf4

Please sign in to comment.