Recommendations for injecting custom code

779
0
10-31-2016 08:50 AM
JadeFreeman
Occasional Contributor III

I'm looking for recommended paths to inject custom code in a supportable manner moving forward.  

One use case is to create a class that persists a users secured services token as long as the token is valid.  This provides a better user experience in an environment where we have a lot of applications that link to our wab application.  Without persisting a users credentials, they end up being forced to log in repeatedly.  The problem with the widget approach is that widgets are not loaded until after the map is instantiated and the user is prompted for credentials.  I'm currently using a separate require block in the init.js file that loads my custom class.

Another use case is to provide an external interface for the search widget.  Several of our applications are being loaded inside a native webview application which supports custom url schemes that launch the application and execute a search.  Rather than reload the whole application whenever the custom url handler takes over and completely lose the losers state, the application uses the external interface to programmatically execute a search.  Currently, I'm extending the Search widget with a mixin which exposed a property and method on the window object that are callable from the native application (iOS).  

I have both of the use cases working but I'm trying to figure out what the best path moving forward is.  I'm afraid upgrading to a newer version of WAB will break things if I don't remember to go back and re-introduce all my customizations.  I haven't found a good way to use version control with WAB either.  I've tried putting my entire WAB installation under version control but then I'm tracking a lot code that I'm not modifying.  I've also tried just putting my custom widgets under version control but this is sort of a pain when you want to use the widget in multiple WAB projects.  Curious to see what others are doing...how are you using WAB in team environments? 

Anyway, looking for ideas/suggestions.

Thanks!

0 Kudos
0 Replies