Skip to content
Discussion options

You must be logged in to vote

@yishn I tried using JsFuture::from(js_promise) but I didn't have a way of running the future. After looking at the link you sent I found a useful function spawn_local which I used in a way that works:

use js_sys::{Object, Reflect};
use wasm_bindgen::JsValue;
use wasm_bindgen_futures::{spawn_local, JsFuture};
use wasm_react::{
    clones, h,
    hooks::{use_effect, use_state, Deps},
    Component, VNode,
};
use web_sys::{console::log_1, window, MediaStreamConstraints};

pub struct CanCamera {}

impl CanCamera {
    pub fn new() -> CanCamera {
        CanCamera {}
    }
}

pub enum PromiseState {
    NotStarted,
    Pending,
    Done(Result<JsValue, JsValue>),
}

impl Component for CanCamera 

Replies: 3 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@yishn
Comment options

Comment options

You must be logged in to vote
2 replies
@ChocolateLoverRaj
Comment options

Answer selected by ChocolateLoverRaj
@yishn
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants