You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In my remote context I expose two classesInnerState and OuterState. Remotely I can construct an InnerState instance.
How do I pass a reference of that InnerState instance to OuterState such that it resolves as a local reference in the remote context instead of a proxied reference?
import{expose,wrap}from'comlink';classInnerState{publicconstructor(privateval: number){}getval(){return`inner: ${this.val}`;}}classOuterState{publicconstructor(privateinnerState: InnerState){}getVal(){return`outer: ${this.innerState.getval()}`;}}constapi={
InnerState,
OuterState,};typeAPI=typeofapi;const{ port1, port2 }=newMessageChannel();expose(api,port1);const{InnerState: InnerStateRemote,OuterState: OuterStateRemote}=wrap<API>(port2);constinnerState=awaitnewInnerStateRemote(7);// TS Error: Argument of type 'Remote<InnerState>' is not assignable to parameter of type 'InnerState'.constouterState=awaitnewOuterStateRemote(innerState);// Expected: "outer: inner: 7"// Actual: "outer: [object Promise]" (and a few other console errors)console.log(awaitouterState.getVal());
Edit: might be a duplicate of #632 but doesn't look like there was a response there, maybe this gets some fresh eyes! :)
The text was updated successfully, but these errors were encountered:
We worked around it by creating a large flat class and avoiding composition. Unfortunate but I'll go ahead and close this in favor of #632 after which hopefully we can refactor to be cleaner!
In my remote context I expose two classes
InnerState
andOuterState
. Remotely I can construct anInnerState
instance.How do I pass a reference of that
InnerState
instance toOuterState
such that it resolves as a local reference in the remote context instead of a proxied reference?Example (and stackblitz):
Edit: might be a duplicate of #632 but doesn't look like there was a response there, maybe this gets some fresh eyes! :)
The text was updated successfully, but these errors were encountered: