rxjs advanced patterns
play

RxJS - Advanced Patterns: Operating Heavily Dynamic UIs Agenda - - PowerPoint PPT Presentation

RxJS - Advanced Patterns: Operating Heavily Dynamic UIs Agenda - The Problem - Reactive Micro Architecture - Event Sourcing, CQRS and their relation - Orchestrate rendering and UI interaction - Where and when to optimize performance


  1. RxJS - Advanced Patterns: Operating Heavily Dynamic UIs

  2. Agenda - The Problem - Reactive Micro Architecture - Event Sourcing, CQRS and their relation - Orchestrate rendering and UI interaction - Where and when to optimize performance @Michael_Hladky

  3. Angular by heart and code Development, Workshops, Community Michael Hladky

  4. The Problem @Michael_Hladky

  5. The Problem - State - Background processes - User interactions @Michael_Hladky

  6. { } Showcase Problem @Michael_Hladky

  7. Micro Architecture @Michael_Hladky

  8. Architecture Sections C O E S H P Constats Divide code into 6 main groups Base Observables Side Effects Structure code with this groups makes code - maintainable Subscription - extensible - easy to orientate Helper Custom Operators @Michael_Hladky

  9. Constants C O E S H P { } Static data i.e. JSON files Constants i.e. interval rate UI elements i.e. Elem. ref. to button TS In some cases a you will extract these things into a separate file . @Michael_Hladky

  10. Base Observables C O E S H P Source observables are the purest observables in you Source Observables architecture. Here we separate into state and interaction. Interaction observables are mostly UI related. Interaction Observables (i.e. btn click) Could be abstracted into a component. State observables represent the state of your State Observables application. In most casts it is in a separate file. Intermediate observables are a combination of state Intermediate Observables and interaction observables. @Michael_Hladky

  11. Side Effects C O E S H P UI Input are all observables that trigger i.e. a UI Updates renderView() function. UI Outputs are all events from user interaction that UI Interaction trigger something else. All actions triggered from automated processes. Background Processes (i.e. intervals, http, web-socket msg’s) @Michael_Hladky

  12. Subscriptions C O E S H P Separate subscriptions into inputs and outputs. Subscription handling should be done declarative. i.e. takeUntil In best case we maintain only a single subscription. Some frameworks even take over subscription handling for us. @Michael_Hladky

  13. Helper C O E S H P Functions that perform common, often reused logic. TS In many cases a you will extract these functions into a separate file. @Michael_Hladky

  14. Custom Operators C O E S H P Creation methods are all functions that Creation methods return a new observable. Operators are all functions that take an Operators observable and return an observable. TS TS In most cases a you will extract these TS functions into separate files. @Michael_Hladky

  15. { } Implement Micro Architecture @Michael_Hladky

  16. Event Sourcing @Michael_Hladky

  17. “ Event Sourcing: Capture all changes to an application state as a sequence ” of events. Martin Fowler

  18. Event Sourcing Modeling state changes as an immutable sequence of events . Every event describes it’s changed to the state. toggle add delete hide edit upsert halfen delete @Michael_Hladky

  19. Event Sourcing [ ] Instead of mutating the state, derive (query) it from the immutable sequence of changes STATE STATE @Michael_Hladky

  20. Command Query Responsibility Segregation (CQRS) CQRS provides separation of concerns for reading and writing. @Michael_Hladky

  21. “ CQRS: Every method should either be a command, or a query, ” but not both. Bertrand Meyer

  22. CQRS Responsibility Segregation Separating an application responsibilities into delete two parts: ● The command side add witch update state edit STATE ● The query side which reads state Command Query @Michael_Hladky

  23. CQRS Rel. DB Oo. DB Enables a combination of [ ] [ ] i.e: ● normalization ( faster writes ) ● denormalization Responsibility Segregation Responsibility Segregation ( faster reads ) Command Command Query Query @Michael_Hladky

  24. CQRS Let’s apply it to the frontend and by Write Read separating writing and reading strictly Responsibility Segregation Command Query @Michael_Hladky

  25. { } Separate State Management and Side Effects @Michael_Hladky

  26. Orchestrate UI interaction and rendering @Michael_Hladky

  27. Orchestrate rendering and UI interaction - First render - Than interaction @Michael_Hladky

  28. Where and when to optimize performance @Michael_Hladky

  29. Where and when to optimize performance - Do it at the end of your task - Before trigger a render side effect - Use the AnimationFrame Scheduler - Sample frequent commands - debounce typing - Use standard operators to work with arrays @Michael_Hladky

  30. Thanks for your time I’m Michael , If you have any questions just ping me ! Michael Hladky

Recommend


More recommend