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

Fluxing Up Your .NET Apps

Fluxing Up Your .NET Apps

Learn about the Flux design pattern and how to implement it in your C# client applications like UWP, Xamarin, and all the other platforms .NET is touching now. We'll compare Flux and Uni-Directional data flows to the existing tools and directions development takes us in C# client apps and talk about all the pros and cons that come with both. We'll take an existing Xamarin.Forms app using MVVM and "Flux it Up" to migrate to a more 1-direction flow of data and actions. When you leave, you'll have a solid understanding of Flux and some of its existing implementations such as Redux and be confident in implementing it yourself in C#!

Now with a Bonus Comet Demo

Avatar for Alex Dunn - SuavePirate

Alex Dunn - SuavePirate

October 02, 2019
Tweet

More Decks by Alex Dunn - SuavePirate

Other Decks in Technology

Transcript

  1. Helps to know…. • Knowledge of building client apps with

    .NET • Familiarity with XAML • Familiarity with MVVM and Bindings • Knowledge of building client apps with React.js • Familiarity with Flux/Redux • Object Oriented JavaScript OR
  2. Resources • Code: https://github.com/SuavePirate/Xamarin.Flux • Library: https://github.com/SuavePirate/FluxToolkit • Flux Docs:

    https://facebook.github.io/flux/docs/overview.html#content • Flux Demos and Examples: https://github.com/facebook/flux • Original Xamarin University Guest Lecture: https://www.youtube.com/watch?v=CmEtXjfdroY
  3. 2. Cross-Base Communication ViewModel Send Data View Receive Data ViewModel

    Send Data View Receive Data ViewModel Send Data View Receive Data
  4. 2. Cross-Base Communication ViewModel Send Data View Receive Data ViewModel

    Send Data View Receive Data ViewModel Send Data View Receive Data
  5. Overview • Client-side Application Architecture / Design Pattern • Designed

    by Facebook • Used for building robust data-driven User Interfaces • Focus on flow of data and separation of concerns • Unidirectional data flows • Built for React.js
  6. From React.jS to C# + Xamarin React.js • Component Render

    • Component State • Component Props • Component Lifecycle C# + Xamarin • XAML/C# Page/View • ViewModel • View Properties • Page Lifecycle and two way binding
  7. Flux Structure Action Dispatcher Store View An action does some

    business logic and communicates data to the dispatcher Dispatcher takes data from action and dispatches it to subscribed stores Takes message from dispatcher and updates data. Emits changes down to observing views View takes updated data from store and updates UI
  8. Flux Structure Action Dispatcher Store View Action Dispatcher Store View

    Action Dispatcher Store View Action Dispatcher Store View Action Dispatcher Store View Action Dispatcher Store View Action Dispatcher Store View Action Dispatcher View Action Dispatcher View on Dispatcher re Dispatcher Store View Action Dispatcher View Action Store View
  9. Uni-direction Data flow Solutions from Flux Trickle Down Control Single

    Source of Truth Plays well with other UI patterns Plays well with architecture patterns
  10. Complex Data Flows - Trickle Down Views Stores Actions Views

    View 1 Action 1 Store 1 View 2 View 1 Store 2 Action 2
  11. Project Structure • Flux Specific Components • TodoActions.cs • TodoActionTypes.cs

    (event identifiers) • TodoStore.cs • Dispatcher (using MessagingCenter from Xamarin.Forms) • MVVM Specific Components • TodoListPageViewModel.cs • TodoListPage.xaml • IoC/DI Specific Components • IoCConfig.cs • ViewModelLocator.cs • Other files are mostly for keeping a clean codebase and maintaining best C# practices