Upgrade to Pro — share decks privately, control downloads, hide ads and more …

SPAs and Micro Services: How does this come together?

SPAs and Micro Services: How does this come together?

Manfred Steyer

January 24, 2019
Tweet

More Decks by Manfred Steyer

Other Decks in Programming

Transcript

  1. @ManfredSteyer SPAs and Micro Services: How does this come together?

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

    Trainings and Consultancy • Google Developer Expert (GDE) Page ▪ 7 Manfred Steyer Public: Wien, München, Stuttgart, Frankfurt In-House: everywhere http://softwarearchitekt.at/workshops
  3. @ManfredSteyer Idea µService µService µService Client Fragment Client Fragment Client

    Fragment ✓ Easy (Tooling) ✓ One optimized bundle set ✓ Consistent  No separate deployment  Mixing Technologies: Difficult  Kopplung npm Packages ?
  4. @ManfredSteyer Disadvantages Distribution • Annoying within project Versioning • Old

    versions • Conflicts • How to force devs to use latest version?
  5. @ManfredSteyer Advantages Everyone uses the latest versions No version conflicts

    No burden with distributing libs Creating new libs: Adding folder Experience: Successfully used at Google, Facebook, …
  6. @ManfredSteyer Advantages Sub Project Sub Project Sub Project Sub Project

    Sub Project Sub Project Sub Project Sub Project
  7. @ManfredSteyer Disadvantages Sub Project Sub Project Sub Project Sub Project

    Sub Project Sub Project Sub Project Sub Project Team A Team B Contract
  8. @ManfredSteyer UI Composition w/ Hyperlinks µApp SPA µApp SPA µApp

    SPA <a href="…">…</a> <a href="…">…</a>
  9. @ManfredSteyer µService Providing a (SPA based) Shell µApp µApp µApp

    Shell ▪ iframes ▪ Bootstrapping several SPAs ▪ + Lazy Loading
  10. @ManfredSteyer Wrap µApps into Web Components • Not a typical

    web component! • But: Unified API for Shell • Nesting
  11. @ManfredSteyer Communication b/w Micro Apps (Web Components) <client-a [state]="appState" (message)="handle($event)"></client-a>

    <client-b [state]="appState" (message)="handle($event)"></client-b> JavaScript in Shell
  12. @ManfredSteyer Bundles Custom Element 1 Custom Element 2 Custom Element

    3 Libraries: Angular, Bootstrap, … Libraries: Angular, Bootstrap, …
  13. @ManfredSteyer Sharing Libs Custom Element 1 Custom Element 2 Custom

    Element 3 Libraries: Angular, Bootstrap, … UMD Drawbacks: Complexity, no isolation
  14. @ManfredSteyer Communication b/w Micro Apps (iframes) <iframe src="…"></iframe> <iframe src="…"></iframe>

    JavaScript in Shell postMessage(…) postMessage(…) message Event message Event
  15. @ManfredSteyer Further Challenges w/ iframes Routing: Sync routes b/w shell

    and iframes Resize iframes to prevent scrolling No overlapping
  16. @ManfredSteyer Disadvantages • Several small and decoupled Projects ;-) •

    More Bundles • Less optimized Bundles/ duplicate Code? • UI Consistency?
  17. @ManfredSteyer Some General Advice Shared state, navigation b/w apps Hyperlinks

    Legacy Apps or *very very* strong isolation? iframes Separate Deployment/ mix Technologies? Web Components Monolith w/ Libs and Monorepo little much yes no yes no Not a good fit for public web sites
  18. @ManfredSteyer Blog > SOFTWAREarchitekt.at • A Software Architect's Approach Towards

    Using Angular (And SPAs In General) For Microservices Aka Microfrontends • A Lightweight And Solid Approach Towards Micro Frontends (Micro Service Clients) With Angular And/Or Other Frameworks • Micro Apps With Web Components Using Angular Elements