member ``.ctor`` : IJSObjectReference -> 'InteropModule)> (jsRuntime: IJSRuntime) =
Мб через новые static abstract методы получится
В принципе есть 2 варианта: static abstract метод функцию конструктор как параметр в конструктор фабрики передавать
В итоге вышло так namespace SkillGro.Teams.Client.Interop.TeamsSDK open System.Threading.Tasks open Microsoft.JSInterop open IcedTasks open SkillGro.Teams.Client.Interop type MicrosoftTeams(``module``: IJSObjectReference) = member _.GetTeamsContextAsync() = ``module``.InvokeAsync<TeamsContext>("getContextAsync") member _.RegisterOnSaveHandlerAsync(settings: TeamsInstanceSettings) = ``module``.InvokeVoidAsync("registerOnSaveHandler", settings) member internal _.IsInTeams() = try ``module``.InvokeAsync<bool>("inTeams") with | :? JSException -> ValueTask.FromResult false member internal _.InitializeAsync() = ``module``.InvokeVoidAsync("initializeAsync") type MicrosoftTeamsFactory(jsRuntime: IJSRuntime) = inherit InteropModuleFactory<MicrosoftTeams voption>(jsRuntime) [<DefaultValue>] val mutable interopModule: MicrosoftTeams voption member factory.ImportModuleAsync() = let factory = factory :> IProtectedInteropModuleFactory task { let! _ = factory.ImportModuleAsync "https://unpkg.com/@microsoft/teams-js@2.17.0/dist/MicrosoftTeams.min.js" return! factory.ImportModuleAsync "./_content/SkillGro.Teams.Interop.Client/js/TeamsJsBlazorInterop.js" } override factory.GetOrCreateAsync() = valueTask { if factory.interopModule = Unchecked.defaultof<_> then let! ``module`` = factory.ImportModuleAsync() let teamsInterop = MicrosoftTeams ``module`` let! isInTeams = teamsInterop.IsInTeams() if isInTeams then factory.interopModule <- ValueSome teamsInterop do! teamsInterop.InitializeAsync() return ValueSome teamsInterop else return ValueNone else return factory.interopModule }
Обсуждают сегодня