Runtime Customizing
Michael Egger-Zikes
for your Angular App
ANGULARarchitects.io
Slide 2
Slide 2 text
Runtime
Customizing
Services
Functions
Micro Apps
Features
Routing
Dependency
Injection
What this talk is about
JSON API
Module
Federation
Michael Egger-Zikes (@MikeZks)
Slide 3
Slide 3 text
About Michael
• Michael Egger-Zikes
ANGULARarchitects.io
• Focus on Angular
• Trainings, Consultancy, Reviews
• Conference Speaker
Public: in-person or remote
In-House: everywhere
angulararchitects.io
/en/angular-workshops
Michael Egger-Zikes
@MikeZks
Slide 4
Slide 4 text
Why do you need
Runtime Customizing
of your Angular App?
?
Slide 5
Slide 5 text
Reasons for Runtime Customizing
• App ships with a feature set included in the main build process
• App settings can modify the runtime behavior
• Customizing is more than changing themes or known settings
• Runtime Customizing allows to hook into the currently running code
Michael Egger-Zikes (@MikeZks)
Slide 6
Slide 6 text
Technology stack
• Angular and the Build Monolith
• Webpack Module Federation
• Angular Routing
• Angular Dependency Injection
• New, custom Dynamic APIs
Michael Egger-Zikes (@MikeZks)
Slide 7
Slide 7 text
Module Federation
• Often connected with Micro Frontends only
• API allows the integration of any exported JavaScript implementation
• Defines what shall be exposed
• Defines what shall be shared
• Allows the integration of new code into a running Angular App
Michael Egger-Zikes (@MikeZks)
Slide 8
Slide 8 text
Challenges
• App needs to be customized w/o a Rebuild
• New features may be deployed while the Shell is running
• App needs to be customized w/o a Browser Reload
• Root-level Services shall be exchanged at runtime
• Routed views may be exchanged on any hierarchal level
• Switch between Default and Plugin behavior needs to work
Michael Egger-Zikes (@MikeZks)
Slide 9
Slide 9 text
Services Functions
Features
Supported Runtime APIs
Micro Apps
Michael Egger-Zikes (@MikeZks)
Slide 10
Slide 10 text
Service Discovery
Module Federation Load
Config
Customizing
Custom Code Types
Module Federation Key
JSON API
Dynamic UI
Widgets
Toggles
Michael Egger-Zikes (@MikeZks)
Slide 11
Slide 11 text
DEMO
Shell
JSON Config
Slide 12
Slide 12 text
Services
• Load Services at Runtime
• Exchange Services w/o Browser Reload
• Exchange even root-level Services
• Custom Services can be switched on & off
Michael Egger-Zikes (@MikeZks)
Slide 13
Slide 13 text
Environment Injector
Platform, Root,
Routes-Array, NgModule
Element Injector
Component
HTML Element (Directive)
Angular Dependency Injection
Michael Egger-Zikes (@MikeZks)
Slide 14
Slide 14 text
Lazy Loading
Known at Shell Build-time
Separate Bundle
Angular supported
Module Federation
Different Build Process
Different Deployment Time
Community supported
Lazy Loading or Module Federation?
Michael Egger-Zikes (@MikeZks)
Slide 15
Slide 15 text
DEMO
Custom Services
Dynamic Provider
Slide 16
Slide 16 text
Functions
• Load Functions at Runtime
• Switch between Default implementation & Plugin logic at Runtime
• Reactive Forms Validation Function as example
• Wrapping Function: concept works for any other Function as well
Michael Egger-Zikes (@MikeZks)
Slide 17
Slide 17 text
DEMO
Custom Functions
Function Wrapper
Slide 18
Slide 18 text
Micro Apps
• Module Federation Single Version approach
• Exposed Routes array
• Like Angular Lazy Loading, but from separate Build process
• Allows full integration into Angular’s Dependency Injection tree
Michael Egger-Zikes (@MikeZks)
Slide 19
Slide 19 text
Features
• Routed Use-Cases as Smart Components with Child Components
• Can be added into present Lazy Loaded Routes
• Integrates into the correct level of the Dependency Injection tree
• Custom Features can be switched on & off
Michael Egger-Zikes (@MikeZks)
Slide 20
Slide 20 text
DEMO
Micro App
Custom Features
Slide 21
Slide 21 text
!
• Default implemention
• Runtime Customizing where needed
• Module Federation integrates code
from separate Build process at
Runtime
• Configuration with JSON/Backend
• Exchange logic w/o Rebuild
• Exchange logic w/o Reload
Key takeaways
Slide 22
Slide 22 text
[web] ANGULARarchitects.io
[twitter] Michael Egger-Zikes (@MikeZks)
[repo] https://github.com/mikezks/ijs-nyc-customizing
Contact • Slides • Code
Remote Workshops:
Public & tailored to your company
angulararchitects.io/angular-workshops