Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce "nodom" binary #882

Merged
merged 20 commits into from
Jul 22, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix local prettier settings
  • Loading branch information
samouri committed Jul 21, 2020
commit 9b1961cccc6409e1aa11e9c8015d90ae4ee34a48
34 changes: 20 additions & 14 deletions demo/call-function/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,37 +9,43 @@
<body>
<div src="call-function.js" id="upgrade-me"></div>
<script type="module">
import { upgradeElement } from "/dist/amp/main.mjs"
import { upgradeElement } from "/dist/amp/main.mjs";
upgradeElement(
document.getElementById("upgrade-me"),
"/dist/amp/worker/worker.nodom.mjs",
"/dist/amp/worker/worker.nodom.mjs"
).then(async (worker) => {
worker
.callFunction("performComplexMath")
.then((result) => console.log(`Complex math result: ${result}`))
.then((result) => console.log(`Complex math result: ${result}`));
worker
.callFunction("getRemoteData")
.then((result) => console.log(`Remote data: ${JSON.stringify(result)}`))
.then((result) => console.log(`Remote data: ${JSON.stringify(result)}`));

const addResult = await worker.callFunction("add", 40, 2)
console.log(`Answer to it all: ${addResult}`)
const addResult = await worker.callFunction("add", 40, 2);
console.log(`Answer to it all: ${addResult}`);

worker
.callFunction("concat", [1, 2, 3], ["4", "5"])
.then((result) => console.log(`concat([1,2,3], ["4", "5"]) is: ${result}`))
.then((result) =>
console.log(`concat([1,2,3], ["4", "5"]) is: ${result}`)
);

worker.callFunction("returnsUndefined").then((result) => {
worker.callFunction('returnsUndefined').then(result => {
console.log(`undefined --> ${result}`)
})

worker.callFunction("reject").catch((err) => console.error(err))
worker.callFunction("tooCoolToExist").catch((err) => console.error(err))
worker.callFunction("immediatelyThrow").catch((err) => console.error(err))
worker.callFunction("reject").catch((err) => console.error(err));
worker
.callFunction("tooCoolToExist")
.catch((err) => console.error(err));
worker
.callFunction("immediatelyThrow")
.catch((err) => console.error(err));

worker.onerror = (err) => {
console.error("Catching an unhandled error: ", err)
}
})
console.error("Catching an unhandled error: ", err);
};
});
</script>
</body>
</html>