Skip to content

Commit

Permalink
Merge pull request #11 from barafael/wasm-main-feature
Browse files Browse the repository at this point in the history
Make `main` optional when compiling to WASM
  • Loading branch information
twitchax committed Jun 6, 2023
2 parents beee607 + 9f88548 commit fea593f
Showing 1 changed file with 1 addition and 10 deletions.
11 changes: 1 addition & 10 deletions src/wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

use std::panic;

use anyhow::Context;

use js_sys::{Array, Object, Reflect};
use wasm_bindgen::{convert::RefFromWasmAbi, prelude::*};

Expand All @@ -28,14 +26,6 @@ static ALLOC: wee_alloc::WeeAlloc<'_> = wee_alloc::WeeAlloc::INIT;
/// The [`Result`] type for the WASM bindings.
pub type JsRes<T> = Result<T, JsValue>;

// Entrypoint setup.

/// The main entrypoint which sets up global state.
#[wasm_bindgen(start)]
pub fn main() {
panic::set_hook(Box::new(console_error_panic_hook::hook));
}

// [`Note`] ABI.

/// The [`Note`] wrapper.
Expand Down Expand Up @@ -335,6 +325,7 @@ impl KordChord {
#[cfg(feature = "audio")]
pub async fn play(&self, delay: f32, length: f32, fade_in: f32) -> JsRes<()> {
use crate::core::base::Playable;
use anyhow::Context;
use gloo_timers::future::TimeoutFuture;

let _handle = self.inner.play(delay, length, fade_in).context("Could not start the playback.").to_js_error()?;
Expand Down

0 comments on commit fea593f

Please sign in to comment.