Micro-Apps and Angular Elements -- Talk from ngMunich, Sep. 2018

15934fa2aa7b2ce21f091e9b7cffa856?s=47 Manfred Steyer
September 04, 2018
170

Micro-Apps and Angular Elements -- Talk from ngMunich, Sep. 2018

Contents:
- Micro Apps
- Web Components/ Custom Elements
- Implementing Micro Apps with Angular Elements
- DEMO
- Recipes

# Samples
https://github.com/manfredsteyer/Angular_MicroApps_Different_Technologies

# More Information and Workshops:
https://www.softwarearchitekt.at

15934fa2aa7b2ce21f091e9b7cffa856?s=128

Manfred Steyer

September 04, 2018
Tweet

Transcript

  1. @ManfredSteyer Maintainable Client Architecture w/ Micro-Apps and Angular Elements Manfred

    Steyer SOFTWAREarchitekt.at ManfredSteyer
  2. @ManfredSteyer About me… • Manfred Steyer • SOFTWAREarchitekt.at • Angular

    Trainings and Consultancy • Google Developer Expert (GDE) Page ▪ 2 Manfred Steyer Public: Munich, November 2018 Early-Bird Tickets available now! Discount Code: ngMunich (15%) In-House: everywhere http://www.softwarearchitekt.at/workshops
  3. @ManfredSteyer ✓ Commodore 64 ✓ 1982 ✓ ~ 1 MHz

    ✓ 64 KB RAM ✓ Disks with 170 KB
  4. @ManfredSteyer Version with two cores ;-) Challenge: Resources!

  5. @ManfredSteyer Challenges today: Complexity

  6. @ManfredSteyer There are milk products lasting longer than some JavaScript

    frameworks
  7. @ManfredSteyer Contents 1) Micro Apps 2) Web Components 3) Implementation

    w/ Angular 4) DEMO
  8. @ManfredSteyer 1) Micro Apps

  9. @ManfredSteyer Idea System

  10. @ManfredSteyer Idea µService µService µService

  11. @ManfredSteyer Idea µApp µApp µApp

  12. @ManfredSteyer Folie▪ 18 Pro Contra

  13. @ManfredSteyer UI Composition w/ Hyperlinks µApp SPA µApp SPA µApp

    SPA
  14. @ManfredSteyer

  15. @ManfredSteyer

  16. @ManfredSteyer ✓ Simple  Loosing State  Load a new

    Application
  17. @ManfredSteyer µService Providing a (SPA based) Shell µApp µApp µApp

    Shell ✓ iframes ✓ Bootstrapping several SPAs ✓ Web Components
  18. @ManfredSteyer 2) Web Components

  19. @ManfredSteyer Framework independent Components

  20. @ManfredSteyer Can be dynamically loaded into the browser!

  21. @ManfredSteyer Umbrella Term for several Standards

  22. @ManfredSteyer Standards Templates HTML Imports Custom Elements Shadow DOM

  23. @ManfredSteyer Custom Elements Custom HTML-Element, e. g. <date-picker> Behaves like

    build-in ones Write once; consume with any framework Can be polyfilled for all current browser
  24. @ManfredSteyer Examples <slider min="0" max="100"> … <customer-selector selected="selected()"> … <my-micro-app

    state="sharedState" message="handle(…)">…
  25. @ManfredSteyer Shadow DOM Isolate CSS Parent cannot influence Component's layout

    Component cannot influence Parent or Siblings Can be emulated for all current browsers (w/ limitations)
  26. @ManfredSteyer µService µApp3 µApp2 µApp1 Shell Web Components for Macro-Architecture

    Shared Widget Shared Widget Shared Widget Web Components for Micro-Architecture
  27. @ManfredSteyer 3) Implementation with Angular

  28. @ManfredSteyer Shadow DOM • Baked-in • Emulation • @Component({ encapsulation:

    ViewEncapsulation.Emulated }) • Default • Shadow DOM • @Component({ encapsulation: ViewEncapsulation.Native }) • Can be turned off: • @Component({ encapsulation: ViewEncapsulation.None })
  29. @ManfredSteyer Custom Elements Angular Elements Wraps Angular Component Expose Custom

    Element
  30. @ManfredSteyer MicroApp as Angular Elements @NgModule({ imports: [BrowserModule], declarations: [MicroAppComponent],

    bootstrap: [], entryComponents: [MicroAppComponent] }) export class AppModule { }
  31. @ManfredSteyer MicroApp as Angular Elements @NgModule({ imports: [BrowserModule], declarations: [MicroAppComponent],

    bootstrap: [], entryComponents: [MicroAppComponent] }) export class AppModule { }
  32. @ManfredSteyer MicroApp as Angular Elements @NgModule({ imports: [BrowserModule], declarations: [MicroAppComponent],

    bootstrap: [], entryComponents: [MicroAppComponent] }) export class AppModule { constructor(private injector: Injector) { } ngDoBootstrap() { } }
  33. @ManfredSteyer MicroApp as Angular Elements @NgModule({ imports: [BrowserModule], declarations: [MicroAppComponent],

    bootstrap: [], entryComponents: [MicroAppComponent] }) export class AppModule { constructor(private injector: Injector) { } ngDoBootstrap() { const MicroAppElement = createCustomElement( MicroAppComponent, { injector: this.injector }); customElements.define('micro-app', MicroAppElement); } }
  34. @ManfredSteyer Loading MicroApps <script src="micro-app.bundle.js"></script> <micro-app></micro-app>

  35. @ManfredSteyer 4) DEMO

  36. @ManfredSteyer Conclusion Separate Deployment Less Coordination Mixing Technologies Shadow DOM

    & Angular Elements Macro vs. Macro Level
  37. @ManfredSteyer Blog > SOFTWAREarchitekt.at • A Software Architect's Approach Towards

    Using Angular (And SPAs In General) For Microservices Aka Microfrontends • Micro Apps With Web Components Using Angular Elements • Angular Elements: A dynamic Dashboard … • Angular, React, Vue.Js And Co. Peacefully United Thanks To Micro Apps And Web Components
  38. @ManfredSteyer Contact and Downloads [mail] manfred.steyer@SOFTWAREarchitekt.at [web] SOFTWAREarchitekt.at [twitter] ManfredSteyer

    d Slides & Examples Munich, November 2018 or In-House Early-Bird Tickets available now! Discount Code: ngMunich (15%) http://www.softwarearchitekt.at/workshops