webaudiomodules / webdx7

virtual Yamaha DX7 synth
https://webaudiomodules.org/wamsynths/dx7
MIT License
139 stars 24 forks source link

How about using `async` functions? #3

Open ghost opened 6 years ago

ghost commented 6 years ago

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

https://github.com/webaudiomodules/webdx7/blob/d056aa3b66eb8252d165060265b33d8e5601e568/dist/dx7/dx7-awn.js#L15-L25

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 commented 6 years ago

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.