Select to view content in your preferred language

Help breaking down widget api references (widget.tsx)

78
2
Jump to solution
yesterday
PLadd
by
Frequent Contributor

I'm trying to breakdown the coding in a widget.tsx file so I can customize to meet my own needs.  In the sample "control-the-widget-state" the first line in the widget.tsx file is this:

import { React, type AllWidgetProps, getAppStore, appActions, ReactRedux, type WidgetProps, WidgetManager, type IMState, WidgetState } from 'jimu-core'
 
I understand what this line is doing but I can't find any documentation for some of these references.  Take "appActions" for example.  If I go to the jimu-core reference page here, there is no reference to a method, class, enumeration, or function called "appActions."  I also looked in the React API library  but found nothing. 
 
Where is the API documentation for some of this stuff?  It goes a long way in helping modify examples to meet my own needs.
1 Solution

Accepted Solutions
JeffreyThompson2
MVP Regular Contributor

Honestly, inadequate documentation, especially on the developer side, is one of the biggest problems holding Experience Builder back. I have learned far more by reading through other people's code than I have the official documentation.

As for the appActions, it is an object with a number of methods for sending data between widgets. For example, this line of code can be used to close a Sidebar Widget.

 getAppStore().dispatch(appActions.widgetStatePropChange(`widget_${sidebarId}`, 'collapse', false))

 

GIS Developer
City of Arlington, Texas

View solution in original post

2 Replies
JeffreyThompson2
MVP Regular Contributor

Honestly, inadequate documentation, especially on the developer side, is one of the biggest problems holding Experience Builder back. I have learned far more by reading through other people's code than I have the official documentation.

As for the appActions, it is an object with a number of methods for sending data between widgets. For example, this line of code can be used to close a Sidebar Widget.

 getAppStore().dispatch(appActions.widgetStatePropChange(`widget_${sidebarId}`, 'collapse', false))

 

GIS Developer
City of Arlington, Texas
TimWestern
Frequent Contributor

@JeffreyThompson2 is right, the documentation at times is not just sparse and limit, but silent on many of these tasks.

I find it sometimes useful to go in with an IDE like Visual Studio (Community or Code), or WebStorm create the code, and than use the tools in them to trace the references down.

That allows me to look at the code file it originates in, so that I can have some idea what its doing.

SO appActions traces to a app-actions.d.ts file under /client/jimu-core/lib/app-acftions.d.ts

However, I'll admit its not obvious if you search that file for appActions that what you are getting is not a 'class' but a module which contains a bunch of 'functions', so in a way the appActions name kind of acts like a namespace? for that file which defines that type.


0 Kudos