Closed YankaZabka closed 2 years ago
Hi @YankaZabka, it all looks good to me. connect()
returns a promised MessagePort
which can then be passed to disconnect()
again.
It looks like you are using Refs in React to store the value. I'm not really a React expert but I know that these things can be very tricky and there might be unexpected race condition when you combine this with other hooks.
Maybe I'm missing something but if connect()
returns a promised MessagePort
and the Ref "forgets" about it I think there is not much that can be done to fix this here. It looks more like a React issue to me.
Yeah, I think you're right. Thanks for the answer!)
Hi! Thanks for this wonderful project. It helped me a lot with recording audio in 'wav' format. But i have an issue:
When my recorder starts I connect the extendable-media-recorder-wav-encoder library via
await register(await connect());
But when the record stops, I want to disconnect from the encoder, how to do it right? I tried to make it throughawait disconnect(refMessagePort.current as MessagePort)
where refMessagePort.current is the value returned by theconnect()
previously. But it doesn't work, because the refMessagePort.current is always null, despite the fact that this code has worked before: