Select to view content in your preferred language

Accessing files from other widgets

561
2
Jump to solution
09-15-2023 03:12 AM
JonathanAttard
Occasional Contributor

Hello,

I'm currently working on creating a Disclaimer widget. The goal is to make this widget easily reusable, allowing other widgets to toggle it on/off and change its description. Essentially, I want one Disclaimer widget to be linked to multiple other widgets.

To formalize this widget, I plan to export an interface and a `setting.tsx` file. However, I've run into an issue where I can't access the interface and `setting.tsx` file from other widgets.

Is there a way to make these Disclaimer files accessible in a manner similar to how we import libraries like `jimu-ui` or `jimu-core`?

Additionally, I'm curious about how to access the functions for showing or hiding the Disclaimer widget once it's linked.

I'd greatly appreciate any guidance or suggestions on how to achieve this or any other alternatives. Thank you!

0 Kudos
1 Solution

Accepted Solutions
JonathanAttard
Occasional Contributor

Thank you for your response. I was able to resolve this issue by using the dispatch function and making some modifications to the client files to create reusable code.

View solution in original post

0 Kudos
2 Replies
JeffreyThompson2
MVP Regular Contributor

If I understand your goals correctly, you want to trigger something like a modal to appear whenever certain widgets do certain things. I would set up my Disclaimer widget to be triggered by a message action in the widget that triggers it. This would require adding a line of code to the triggering widget similar to this: MutableStoreManager.getInstance().updateStateValue('idOfDisclamerWidget', 'messageName', message) So, that may not meet your reusability requirement, but the Disclaimer widget could be triggered to do multiple things based on the message received.

GIS Developer
City of Arlington, Texas
0 Kudos
JonathanAttard
Occasional Contributor

Thank you for your response. I was able to resolve this issue by using the dispatch function and making some modifications to the client files to create reusable code.

0 Kudos