Skip to content

Commit

Permalink
Use EventAggregator to decouple exception handler and UI
Browse files Browse the repository at this point in the history
  • Loading branch information
adamhathcock committed Nov 28, 2024
1 parent 7a71b5d commit bb0faaa
Show file tree
Hide file tree
Showing 46 changed files with 299 additions and 99 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,14 @@ public class ArcGISSelectionBinding : ISelectionBinding
public string Name => "selectionBinding";
public IBrowserBridge Parent { get; }

public ArcGISSelectionBinding(IBrowserBridge parent, MapMembersUtils mapMemberUtils)
public ArcGISSelectionBinding(IBrowserBridge parent, MapMembersUtils mapMemberUtils, ITopLevelExceptionHandler topLevelExceptionHandler)
{
_mapMemberUtils = mapMemberUtils;
Parent = parent;
var topLevelHandler = parent.TopLevelExceptionHandler;

// example: https://github.com/Esri/arcgis-pro-sdk-community-samples/blob/master/Map-Authoring/QueryBuilderControl/DefinitionQueryDockPaneViewModel.cs
// MapViewEventArgs args = new(MapView.Active);
TOCSelectionChangedEvent.Subscribe(_ => topLevelHandler.CatchUnhandled(OnSelectionChanged), true);
TOCSelectionChangedEvent.Subscribe(_ => topLevelExceptionHandler.CatchUnhandled(OnSelectionChanged), true);
}

private void OnSelectionChanged()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public ArcGISSendBinding(
IOperationProgressManager operationProgressManager,
ILogger<ArcGISSendBinding> logger,
IArcGISConversionSettingsFactory arcGisConversionSettingsFactory,
ITopLevelExceptionHandler topLevelExceptionHandler,
MapMembersUtils mapMemberUtils
)
{
Expand All @@ -76,7 +77,7 @@ MapMembersUtils mapMemberUtils
_sendConversionCache = sendConversionCache;
_operationProgressManager = operationProgressManager;
_logger = logger;
_topLevelExceptionHandler = parent.TopLevelExceptionHandler;
_topLevelExceptionHandler = topLevelExceptionHandler;
_arcGISConversionSettingsFactory = arcGisConversionSettingsFactory;
_mapMemberUtils = mapMemberUtils;

Expand Down Expand Up @@ -190,23 +191,23 @@ private void SubscribeToAnyDataSourceChange(Table layerTable)
{
RowCreatedEvent.Subscribe(
(args) =>
Parent.TopLevelExceptionHandler.FireAndForget(async () =>
_topLevelExceptionHandler.FireAndForget(async () =>
{
await OnRowChanged(args).ConfigureAwait(false);
}),
layerTable
);
RowChangedEvent.Subscribe(
(args) =>
Parent.TopLevelExceptionHandler.FireAndForget(async () =>
_topLevelExceptionHandler.FireAndForget(async () =>
{
await OnRowChanged(args).ConfigureAwait(false);
}),
layerTable
);
RowDeletedEvent.Subscribe(
(args) =>
Parent.TopLevelExceptionHandler.FireAndForget(async () =>
_topLevelExceptionHandler.FireAndForget(async () =>
{
await OnRowChanged(args).ConfigureAwait(false);
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ public class BasicConnectorBinding : IBasicConnectorBinding
private readonly DocumentModelStore _store;
private readonly ISpeckleApplication _speckleApplication;

public BasicConnectorBinding(DocumentModelStore store, IBrowserBridge parent, ISpeckleApplication speckleApplication)
public BasicConnectorBinding(DocumentModelStore store, IBrowserBridge parent, ISpeckleApplication speckleApplication, ITopLevelExceptionHandler topLevelExceptionHandler)
{
_store = store;
_speckleApplication = speckleApplication;
Parent = parent;
Commands = new BasicConnectorBindingCommands(parent);

_store.DocumentChanged += (_, _) =>
parent.TopLevelExceptionHandler.FireAndForget(async () =>
topLevelExceptionHandler.FireAndForget(async () =>
{
await Commands.NotifyDocumentChanged().ConfigureAwait(false);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,11 @@
"resolved": "8.0.0",
"contentHash": "dk9JPxTCIevS75HyEQ0E4OVAFhB2N+V9ShCXf8Q6FkUQZDkgLI12y679Nym1YqsiSysuQskT7Z+6nUf3yab6Vw=="
},
"Prism.Events": {
"type": "Transitive",
"resolved": "9.0.537",
"contentHash": "Pzp5MGUuhAyKXZUbHVYNWLGF/eA3sScqDN6VrzbWlKj85R0IS0q+JXe99umynso2xhXAe+1jrQCCkgqmEFCBng=="
},
"Speckle.DoubleNumerics": {
"type": "Transitive",
"resolved": "4.0.1",
Expand Down Expand Up @@ -240,6 +245,7 @@
"type": "Project",
"dependencies": {
"Microsoft.Extensions.Logging.Abstractions": "[2.2.0, )",
"Prism.Events": "[9.0.537, )",
"Speckle.Connectors.Common": "[1.0.0, )",
"Speckle.Sdk": "[3.1.0-dev.200, )",
"Speckle.Sdk.Dependencies": "[3.1.0-dev.200, )"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,11 @@
"resolved": "8.0.0",
"contentHash": "dk9JPxTCIevS75HyEQ0E4OVAFhB2N+V9ShCXf8Q6FkUQZDkgLI12y679Nym1YqsiSysuQskT7Z+6nUf3yab6Vw=="
},
"Prism.Events": {
"type": "Transitive",
"resolved": "9.0.537",
"contentHash": "Pzp5MGUuhAyKXZUbHVYNWLGF/eA3sScqDN6VrzbWlKj85R0IS0q+JXe99umynso2xhXAe+1jrQCCkgqmEFCBng=="
},
"Speckle.DoubleNumerics": {
"type": "Transitive",
"resolved": "4.0.1",
Expand Down Expand Up @@ -273,6 +278,7 @@
"type": "Project",
"dependencies": {
"Microsoft.Extensions.Logging.Abstractions": "[2.2.0, )",
"Prism.Events": "[9.0.537, )",
"Speckle.Connectors.Common": "[1.0.0, )",
"Speckle.Sdk": "[3.1.0-dev.200, )",
"Speckle.Sdk.Dependencies": "[3.1.0-dev.200, )"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,11 @@
"resolved": "8.0.0",
"contentHash": "dk9JPxTCIevS75HyEQ0E4OVAFhB2N+V9ShCXf8Q6FkUQZDkgLI12y679Nym1YqsiSysuQskT7Z+6nUf3yab6Vw=="
},
"Prism.Events": {
"type": "Transitive",
"resolved": "9.0.537",
"contentHash": "Pzp5MGUuhAyKXZUbHVYNWLGF/eA3sScqDN6VrzbWlKj85R0IS0q+JXe99umynso2xhXAe+1jrQCCkgqmEFCBng=="
},
"Speckle.DoubleNumerics": {
"type": "Transitive",
"resolved": "4.0.1",
Expand Down Expand Up @@ -273,6 +278,7 @@
"type": "Project",
"dependencies": {
"Microsoft.Extensions.Logging.Abstractions": "[2.2.0, )",
"Prism.Events": "[9.0.537, )",
"Speckle.Connectors.Common": "[1.0.0, )",
"Speckle.Sdk": "[3.1.0-dev.200, )",
"Speckle.Sdk.Dependencies": "[3.1.0-dev.200, )"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,11 @@
"resolved": "8.0.0",
"contentHash": "dk9JPxTCIevS75HyEQ0E4OVAFhB2N+V9ShCXf8Q6FkUQZDkgLI12y679Nym1YqsiSysuQskT7Z+6nUf3yab6Vw=="
},
"Prism.Events": {
"type": "Transitive",
"resolved": "9.0.537",
"contentHash": "Pzp5MGUuhAyKXZUbHVYNWLGF/eA3sScqDN6VrzbWlKj85R0IS0q+JXe99umynso2xhXAe+1jrQCCkgqmEFCBng=="
},
"Speckle.DoubleNumerics": {
"type": "Transitive",
"resolved": "4.0.1",
Expand Down Expand Up @@ -273,6 +278,7 @@
"type": "Project",
"dependencies": {
"Microsoft.Extensions.Logging.Abstractions": "[2.2.0, )",
"Prism.Events": "[9.0.537, )",
"Speckle.Connectors.Common": "[1.0.0, )",
"Speckle.Sdk": "[3.1.0-dev.200, )",
"Speckle.Sdk.Dependencies": "[3.1.0-dev.200, )"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,11 @@
"resolved": "8.0.0",
"contentHash": "dk9JPxTCIevS75HyEQ0E4OVAFhB2N+V9ShCXf8Q6FkUQZDkgLI12y679Nym1YqsiSysuQskT7Z+6nUf3yab6Vw=="
},
"Prism.Events": {
"type": "Transitive",
"resolved": "9.0.537",
"contentHash": "Pzp5MGUuhAyKXZUbHVYNWLGF/eA3sScqDN6VrzbWlKj85R0IS0q+JXe99umynso2xhXAe+1jrQCCkgqmEFCBng=="
},
"Speckle.DoubleNumerics": {
"type": "Transitive",
"resolved": "4.0.1",
Expand Down Expand Up @@ -229,6 +234,7 @@
"type": "Project",
"dependencies": {
"Microsoft.Extensions.Logging.Abstractions": "[2.2.0, )",
"Prism.Events": "[9.0.537, )",
"Speckle.Connectors.Common": "[1.0.0, )",
"Speckle.Sdk": "[3.1.0-dev.200, )",
"Speckle.Sdk.Dependencies": "[3.1.0-dev.200, )"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public AutocadBasicConnectorBinding(
IAccountManager accountManager,
ISpeckleApplication speckleApplication,
ILogger<AutocadBasicConnectorBinding> logger,
ITopLevelExceptionHandler topLevelExceptionHandler,
IThreadContext threadContext
)
{
Expand All @@ -40,7 +41,7 @@ IThreadContext threadContext
_speckleApplication = speckleApplication;
Commands = new BasicConnectorBindingCommands(parent);
_store.DocumentChanged += (_, _) =>
parent.TopLevelExceptionHandler.FireAndForget(async () =>
topLevelExceptionHandler.FireAndForget(async () =>
{
await Commands.NotifyDocumentChanged().ConfigureAwait(false);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ public class AutocadSelectionBinding : ISelectionBinding

public IBrowserBridge Parent { get; }

public AutocadSelectionBinding(IBrowserBridge parent, IThreadContext threadContext)
public AutocadSelectionBinding(IBrowserBridge parent, IThreadContext threadContext, ITopLevelExceptionHandler topLevelExceptionHandler)
{
_topLevelExceptionHandler = parent.TopLevelExceptionHandler;
_topLevelExceptionHandler = topLevelExceptionHandler;
Parent = parent;
_threadContext = threadContext;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ protected AutocadSendBaseBinding(
IOperationProgressManager operationProgressManager,
ILogger<AutocadSendBinding> logger,
ISpeckleApplication speckleApplication,
ITopLevelExceptionHandler topLevelExceptionHandler,
IThreadContext threadContext
)
{
Expand All @@ -73,7 +74,7 @@ IThreadContext threadContext
_logger = logger;
_speckleApplication = speckleApplication;
_threadContext = threadContext;
_topLevelExceptionHandler = parent.TopLevelExceptionHandler;
_topLevelExceptionHandler =topLevelExceptionHandler;
Parent = parent;
Commands = new SendBindingUICommands(parent);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public AutocadSendBinding(
ILogger<AutocadSendBinding> logger,
IAutocadConversionSettingsFactory autocadConversionSettingsFactory,
ISpeckleApplication speckleApplication,
ITopLevelExceptionHandler topLevelExceptionHandler,
IThreadContext threadContext
)
: base(
Expand All @@ -43,6 +44,7 @@ IThreadContext threadContext
operationProgressManager,
logger,
speckleApplication,
topLevelExceptionHandler,
threadContext
)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,11 @@
"resolved": "8.0.0",
"contentHash": "dk9JPxTCIevS75HyEQ0E4OVAFhB2N+V9ShCXf8Q6FkUQZDkgLI12y679Nym1YqsiSysuQskT7Z+6nUf3yab6Vw=="
},
"Prism.Events": {
"type": "Transitive",
"resolved": "9.0.537",
"contentHash": "Pzp5MGUuhAyKXZUbHVYNWLGF/eA3sScqDN6VrzbWlKj85R0IS0q+JXe99umynso2xhXAe+1jrQCCkgqmEFCBng=="
},
"Speckle.DoubleNumerics": {
"type": "Transitive",
"resolved": "4.0.1",
Expand Down Expand Up @@ -282,6 +287,7 @@
"type": "Project",
"dependencies": {
"Microsoft.Extensions.Logging.Abstractions": "[2.2.0, )",
"Prism.Events": "[9.0.537, )",
"Speckle.Connectors.Common": "[1.0.0, )",
"Speckle.Sdk": "[3.1.0-dev.200, )",
"Speckle.Sdk.Dependencies": "[3.1.0-dev.200, )"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,11 @@
"resolved": "8.0.0",
"contentHash": "dk9JPxTCIevS75HyEQ0E4OVAFhB2N+V9ShCXf8Q6FkUQZDkgLI12y679Nym1YqsiSysuQskT7Z+6nUf3yab6Vw=="
},
"Prism.Events": {
"type": "Transitive",
"resolved": "9.0.537",
"contentHash": "Pzp5MGUuhAyKXZUbHVYNWLGF/eA3sScqDN6VrzbWlKj85R0IS0q+JXe99umynso2xhXAe+1jrQCCkgqmEFCBng=="
},
"Speckle.DoubleNumerics": {
"type": "Transitive",
"resolved": "4.0.1",
Expand Down Expand Up @@ -282,6 +287,7 @@
"type": "Project",
"dependencies": {
"Microsoft.Extensions.Logging.Abstractions": "[2.2.0, )",
"Prism.Events": "[9.0.537, )",
"Speckle.Connectors.Common": "[1.0.0, )",
"Speckle.Sdk": "[3.1.0-dev.200, )",
"Speckle.Sdk.Dependencies": "[3.1.0-dev.200, )"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,11 @@
"resolved": "8.0.0",
"contentHash": "dk9JPxTCIevS75HyEQ0E4OVAFhB2N+V9ShCXf8Q6FkUQZDkgLI12y679Nym1YqsiSysuQskT7Z+6nUf3yab6Vw=="
},
"Prism.Events": {
"type": "Transitive",
"resolved": "9.0.537",
"contentHash": "Pzp5MGUuhAyKXZUbHVYNWLGF/eA3sScqDN6VrzbWlKj85R0IS0q+JXe99umynso2xhXAe+1jrQCCkgqmEFCBng=="
},
"Speckle.DoubleNumerics": {
"type": "Transitive",
"resolved": "4.0.1",
Expand Down Expand Up @@ -282,6 +287,7 @@
"type": "Project",
"dependencies": {
"Microsoft.Extensions.Logging.Abstractions": "[2.2.0, )",
"Prism.Events": "[9.0.537, )",
"Speckle.Connectors.Common": "[1.0.0, )",
"Speckle.Sdk": "[3.1.0-dev.200, )",
"Speckle.Sdk.Dependencies": "[3.1.0-dev.200, )"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,11 @@
"resolved": "8.0.0",
"contentHash": "dk9JPxTCIevS75HyEQ0E4OVAFhB2N+V9ShCXf8Q6FkUQZDkgLI12y679Nym1YqsiSysuQskT7Z+6nUf3yab6Vw=="
},
"Prism.Events": {
"type": "Transitive",
"resolved": "9.0.537",
"contentHash": "Pzp5MGUuhAyKXZUbHVYNWLGF/eA3sScqDN6VrzbWlKj85R0IS0q+JXe99umynso2xhXAe+1jrQCCkgqmEFCBng=="
},
"Speckle.DoubleNumerics": {
"type": "Transitive",
"resolved": "4.0.1",
Expand Down Expand Up @@ -238,6 +243,7 @@
"type": "Project",
"dependencies": {
"Microsoft.Extensions.Logging.Abstractions": "[2.2.0, )",
"Prism.Events": "[9.0.537, )",
"Speckle.Connectors.Common": "[1.0.0, )",
"Speckle.Sdk": "[3.1.0-dev.200, )",
"Speckle.Sdk.Dependencies": "[3.1.0-dev.200, )"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public Civil3dSendBinding(
ICivil3dConversionSettingsFactory civil3dConversionSettingsFactory,
IAutocadConversionSettingsFactory autocadConversionSettingsFactory,
ISpeckleApplication speckleApplication,
ITopLevelExceptionHandler topLevelExceptionHandler,
IThreadContext threadContext
)
: base(
Expand All @@ -47,6 +48,7 @@ IThreadContext threadContext
operationProgressManager,
logger,
speckleApplication,
topLevelExceptionHandler,
threadContext
)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,11 @@
"resolved": "8.0.0",
"contentHash": "dk9JPxTCIevS75HyEQ0E4OVAFhB2N+V9ShCXf8Q6FkUQZDkgLI12y679Nym1YqsiSysuQskT7Z+6nUf3yab6Vw=="
},
"Prism.Events": {
"type": "Transitive",
"resolved": "9.0.537",
"contentHash": "Pzp5MGUuhAyKXZUbHVYNWLGF/eA3sScqDN6VrzbWlKj85R0IS0q+JXe99umynso2xhXAe+1jrQCCkgqmEFCBng=="
},
"Speckle.DoubleNumerics": {
"type": "Transitive",
"resolved": "4.0.1",
Expand Down Expand Up @@ -301,6 +306,7 @@
"type": "Project",
"dependencies": {
"Microsoft.Extensions.Logging.Abstractions": "[2.2.0, )",
"Prism.Events": "[9.0.537, )",
"Speckle.Connectors.Common": "[1.0.0, )",
"Speckle.Sdk": "[3.1.0-dev.200, )",
"Speckle.Sdk.Dependencies": "[3.1.0-dev.200, )"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,11 @@
"resolved": "8.0.0",
"contentHash": "dk9JPxTCIevS75HyEQ0E4OVAFhB2N+V9ShCXf8Q6FkUQZDkgLI12y679Nym1YqsiSysuQskT7Z+6nUf3yab6Vw=="
},
"Prism.Events": {
"type": "Transitive",
"resolved": "9.0.537",
"contentHash": "Pzp5MGUuhAyKXZUbHVYNWLGF/eA3sScqDN6VrzbWlKj85R0IS0q+JXe99umynso2xhXAe+1jrQCCkgqmEFCBng=="
},
"Speckle.DoubleNumerics": {
"type": "Transitive",
"resolved": "4.0.1",
Expand Down Expand Up @@ -301,6 +306,7 @@
"type": "Project",
"dependencies": {
"Microsoft.Extensions.Logging.Abstractions": "[2.2.0, )",
"Prism.Events": "[9.0.537, )",
"Speckle.Connectors.Common": "[1.0.0, )",
"Speckle.Sdk": "[3.1.0-dev.200, )",
"Speckle.Sdk.Dependencies": "[3.1.0-dev.200, )"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,11 @@
"resolved": "8.0.0",
"contentHash": "dk9JPxTCIevS75HyEQ0E4OVAFhB2N+V9ShCXf8Q6FkUQZDkgLI12y679Nym1YqsiSysuQskT7Z+6nUf3yab6Vw=="
},
"Prism.Events": {
"type": "Transitive",
"resolved": "9.0.537",
"contentHash": "Pzp5MGUuhAyKXZUbHVYNWLGF/eA3sScqDN6VrzbWlKj85R0IS0q+JXe99umynso2xhXAe+1jrQCCkgqmEFCBng=="
},
"Speckle.DoubleNumerics": {
"type": "Transitive",
"resolved": "4.0.1",
Expand Down Expand Up @@ -301,6 +306,7 @@
"type": "Project",
"dependencies": {
"Microsoft.Extensions.Logging.Abstractions": "[2.2.0, )",
"Prism.Events": "[9.0.537, )",
"Speckle.Connectors.Common": "[1.0.0, )",
"Speckle.Sdk": "[3.1.0-dev.200, )",
"Speckle.Sdk.Dependencies": "[3.1.0-dev.200, )"
Expand Down
Loading

0 comments on commit bb0faaa

Please sign in to comment.