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

How about using async functions? #3

Open
ghost opened this issue Apr 5, 2018 · 1 comment
Open

How about using async functions? #3

ghost opened this issue Apr 5, 2018 · 1 comment

Comments

@ghost
Copy link

ghost commented Apr 5, 2018

What do you think about using async functions to prevent callback hells?

static importScripts (actx) {
var origin = location.origin + "/";
return new Promise( (resolve) => {
actx.audioWorklet.addModule(origin + "dx7/wasm/dx7.wasm.js").then(() => {
actx.audioWorklet.addModule(origin + "dx7/wasm/dx7.js").then(() => {
actx.audioWorklet.addModule(origin + "../wamsdk/wam-processor.js").then(() => {
actx.audioWorklet.addModule(origin + "dx7/dx7-awp.js").then(() => {
resolve();
}) }) }) });
})
}

static async importScripts(actx)
{
	const origin = location.origin + '/';
	await actx.audioWorklet.addModule(origin + "dx7/wasm/dx7.wasm.js");
	await actx.audioWorklet.addModule(origin + "dx7/wasm/dx7.js");
	await actx.audioWorklet.addModule(origin + "../wamsdk/wam-processor.js");
	await actx.audioWorklet.addModule(origin + "dx7/dx7-awp.js");
}
@jariseon
Copy link
Member

jariseon commented Apr 6, 2018

yeah async/await makes it much more cleaner, and looks like all major browser support it. thanks, i will clean this up in next update. WASM code transfer to processor side will also be greatly simplified once constructor (options) becomes available.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant