jccartwright / exb-widgets

sandbox for custom widgets to be used in ArcGIS Experience Builder
0 stars 1 forks source link

how to pass data from DataSourceFilterChange message to widget #5

Closed jccartwright closed 2 years ago

jccartwright commented 2 years ago

Action handler, e.g. MessageHandlerAction is receiving framework message but lacks a good way to pass that on to the widget since the content of the message does not change with filter changes.

Can the datasource referenced in the message body be queried in the MessageHandlerAction to retrieve the queryParams and pass that as string?

shawnmgoulet commented 2 years ago

I want to state this back a bit differently to confirm above with another explanation (using DataSourceFilterChangeMessage as an example):

DataSourceFilterChangeMessage contains the type, widgetId, and the dataSourceId props.

If the DataSource is a QueriableDataSource, for instance, then an option could be to:

  1. use the dataSourceId returned from the message to select the appropriate DataSource
  2. invoke QueriableDataSource.getCurrentQueryParams() like you are doing within your datasource-record-count widget and is done in a few OOTB widgets
jccartwright commented 2 years ago

The DataSource referenced by the dataSourceId in the message is a QueriableDataSource.

However, I'm not clear on how to construct a QueriableDataSource given that Id.

Ideally this could be done w/in the Action handler and then pass the queryParams as a string to trigger the widget's componentDidUpdate method

jccartwright commented 2 years ago

although I don't know if it's the best approach, I now have a working version. Using DataSourceManager to get the DataSource and ultimately the currentQueryParams and then passing that string which triggers the componentDidUpdate method.

shawnmgoulet commented 2 years ago

Thanks @jccartwright. This implementation was added in this commit, yes?

https://github.com/jccartwright/exb-widgets/commit/41a2ad8b39d6ba5c59cb66d0650217b9b2c07c0c

jccartwright commented 2 years ago

Basically yes, although I significantly improved it in more recent commits in converting to functional component and using Redux hook.

If you’ve got some time tomorrow, I can walk you through what I now have on this and the client-side layer.

On Sep 6, 2022, at 9:28 AM, Shawn Goulet @.***> wrote:

Thanks @jccartwright https://github.com/jccartwright. This implementation was added in this commit, yes?

41a2ad8 https://github.com/jccartwright/exb-widgets/commit/41a2ad8b39d6ba5c59cb66d0650217b9b2c07c0c — Reply to this email directly, view it on GitHub https://github.com/jccartwright/exb-widgets/issues/5#issuecomment-1238309015, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAHAEBVJLN3YHRY44ZNN3DLV45PJLANCNFSM577P55CA. You are receiving this because you were mentioned.

jccartwright commented 2 years ago

please review and comment on approach used in subscriber-demo

shawnmgoulet commented 2 years ago

I think this approach, when not needing config options, is sound. I see the DataRecordsSelectionChange coming through in the console and the way you set it up as a functional component makes sense to me.