Skip to content

Commit

Permalink
Instance
Browse files Browse the repository at this point in the history
  • Loading branch information
artemiusgreat committed Mar 20, 2024
1 parent 169003f commit f0c9528
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Libs/ScriptContainer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<PropertyGroup>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<Version>1.2.7</Version>
<Version>1.2.8</Version>
<Authors>artemiusgreat</Authors>
<Copyright>indemos.com</Copyright>
<PackageProjectUrl>http://indemos.com</PackageProjectUrl>
Expand Down
15 changes: 10 additions & 5 deletions Libs/ScriptService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,13 @@ public async Task<string> SubscribeToSize(ElementReference element, string actio
/// <returns></returns>
public async Task<ScriptService> CreateModule(IDictionary<string, dynamic> options = null)
{
_serviceInstance = DotNetObjectReference.Create(this);
_scriptModule = await _runtime.InvokeAsync<IJSObjectReference>("import", $"./_content/ScriptContainer/ScriptControl.razor.js?{Guid.NewGuid()}");
_scriptInstance = await _scriptModule.InvokeAsync<IJSObjectReference>("getScriptModule", _serviceInstance, options ?? new Dictionary<string, object>());
try
{
_serviceInstance = DotNetObjectReference.Create(this);
_scriptModule = await _runtime.InvokeAsync<IJSObjectReference>("import", $"./_content/ScriptContainer/ScriptControl.razor.js?{Guid.NewGuid()}");
_scriptInstance = await _scriptModule.InvokeAsync<IJSObjectReference>("getScriptModule", _serviceInstance, options ?? new Dictionary<string, object>());
}
catch (Exception) { }

return this;
}
Expand All @@ -126,10 +130,11 @@ public async Task<ScriptService> CreateModule(IDictionary<string, dynamic> optio
[JSInvokable]
public void OnChange(dynamic message, string actionName)
{
if (Actions.TryGetValue(actionName, out var action)) {
if (Actions.TryGetValue(actionName, out var action))
{
action(message);
}
}
}

/// <summary>
/// Dispose
Expand Down

0 comments on commit f0c9528

Please sign in to comment.