I hope I didn't miss any appropriate solution from another topic. Like the topic says, I'm using blazor with interop calls. That works fine, but now my TypeScript file with the class definition uses another TS module via import. Later I added the script with the type="module" attribute, to avoid another issue. Now my interop calls (via JSRuntime) to this script functions doesn't work anymore, probably because of the limited scope of the module classes and variables?
Before the code follows, thanks a lot for your help !
Sample class in CanvasFeeder.ts/js with Method to call via interop:
export class CanvasFeeder
{
public InitCanvas(){ }
}
export * as CanvasFeed from "CanvasFeeder";
var MyCanvasFeeder = new CanvasFeeder();
var ToCallInterop = () => {MyCanvasFeeder.InitCanvas();};
Script reference index.html:
<script src="typescript/CanvasFeeder.js" type="module"></script>
What have I tried?
JSRuntime.InvokeVoidAsync("ToCallInterop");
JSRuntime.InvokeVoidAsync("MyCanvasFeeder.ToCallInterop");
I also tried to instantiate the class and function directly in the index.html.
What are the error message?
- Unhandled exception: Could not find 'ToCallInterop'
- Unhandled exception: 'ToCallInterop' is not a variable (when instantiating var directly in area of index.html