Blazor MVVM Part 1: Carl Franklin's Blazor Train ep 24

Поділитися
Вставка
  • Опубліковано 26 січ 2025

КОМЕНТАРІ • 38

  • @ahmedtalaat27
    @ahmedtalaat27 13 днів тому

    this is what i call professionalism

  • @liquidpebbles
    @liquidpebbles 4 роки тому +3

    Ive got to go clean up my super scrappy website to use MVVM now. Thanks so much for the very straight forward explanation and walk through!

    • @debeerpaul
      @debeerpaul 2 місяці тому

      How did it work for you? Whats your take on blazor and are you still using it?

    • @liquidpebbles
      @liquidpebbles 2 місяці тому

      ​@@debeerpaul I can't remember if I ever did implement any MVVM, but the company was satisfied with the website. I like Blazor, as a developer, but I think the trade offs on wasm (long startup times) and signalr (weird rendering, re-rendering issues, reconnection issues) don't really draw me back to using it on other projects.
      I did play around with ssr and it caught my attention for a bit. I think ssr Blazor with signal r in select places might be wonderful but I haven't given it a fair shake.
      Generally now I just use razor pages with some javascript to do what I need. Note I'm not making big fancy web apps. Mostly just admin panels.

    • @debeerpaul
      @debeerpaul 2 місяці тому

      @@liquidpebbles Thanks yes we are experiencing the exact same issues with the signalR websockets taking long to update appstates etc on slow connections.

  • @tk5782
    @tk5782 9 місяців тому +1

    What do we actually gain from the additional effort? We could inject a different version of the vm in testing maybe, but what is the return on investment here?

  • @williambell4591
    @williambell4591 4 роки тому +2

    Thanks you so much for this Chris - I appreciate you so much, for this series of yours! Toot your horn, brother!

  • @ryandavis7506
    @ryandavis7506 3 роки тому +1

    Nice tutorial. Question - this version of MVVM looks so much different (and more intuitive I'd add) then the traditional MVVM (INotify..., Set, OnPropChange...; etc.). Can you explain why you implemented MVVM this way as opposed to the more traditional way? Also, I noticed that doing it your way you cannot call StateHasChanged in the ViewModel due to an issue with something called a RenderHandle. Is there a solution that exists for that without putting the code in the @code { } section or in a code-behind?

    • @DeveloperExpress
      @DeveloperExpress  3 роки тому

      Thanks Ryan. This implementation is particular to Blazor, which does not require INotifyPropertyChanged. As Carl recalls, he added an event handler which you can hook to call StateHasChanged.

    • @drdream123
      @drdream123 2 роки тому +1

      I always use INotifyPropertyChanged in Blazor. How is your UI notified of changes? Even today with .Net 6 if i forget to propertychanged a value then the UI does not know about it.. especially with SignalR

  • @dmitrybelov5703
    @dmitrybelov5703 3 роки тому

    6:55 mistake in NewCustomer(). Setting new Id as Count +1 is not a good idea. if You delete first customer an then add new one - you'll get two ( or even more ) customers with id = 3

  • @paulstanley2789
    @paulstanley2789 4 роки тому

    Hi Carl thanks for the great vid. How is the UI notified of property changes in the ViewModel?

    • @DeveloperExpress
      @DeveloperExpress  4 роки тому

      Hi Paul. Thanks for the question. The answer is Basic Binding. Everything in the ViewModel is a property or a Task - all done with binding, so StateHasChanged happens automatically. But, in the case where it doesn't work, you could expose an OnStateHasChanged event, meaning you'd have one code-behind event handler that called StateHasChanged.

    • @carlfranklin7894
      @carlfranklin7894 4 роки тому

      On Monday I'll show you how to raise an event in a business model when a property changes so the viewmodel can do whatever it needs to do to update the view.

  • @zimcoder
    @zimcoder 3 роки тому

    Hi Carl, how do I use Parameters with a ViewModel? My view defines a parameter to receive data from another component how do I pass that value to initialise the ViewModel?

    • @DeveloperExpress
      @DeveloperExpress  3 роки тому

      Hi Clement. One way is to create an Initialize method on the ViewModel, that you can call from the view.

  • @DanKCarlsbad
    @DanKCarlsbad 4 роки тому

    Any plans to have a video that implements the DevExpress Blazor Data Grid control?

    • @DeveloperExpress
      @DeveloperExpress  4 роки тому

      Hi Daniel, have you seen this video?
      ua-cam.com/video/VXqxKFjZLwk/v-deo.html

    • @DeveloperExpress
      @DeveloperExpress  4 роки тому

      If you need help with DevExpress Blazor Data Grid and MVVM, please contact our support team and they can help you: devexpress.com/ask

    • @carlfranklin7894
      @carlfranklin7894 4 роки тому

      As a matter of fact, yes. I plan on covering the Dx data grid control later this year.

  • @cslewis47
    @cslewis47 3 роки тому

    thanks Carl. Very helpful! I enjoy the videos.

  • @5ROC
    @5ROC 2 роки тому

    Excellent ! 😀

  • @soohyunjeon9348
    @soohyunjeon9348 7 місяців тому

    Thank you~! you are the best!!

  • @ovedurak
    @ovedurak 4 роки тому

    What is the benefit of using this versus a nice razor.cs file that does all the work?
    I usually have a simple DTO, a .razor blazor page and a razor.cs backing file... isn't that essentially doing the same thing?

    • @carlfranklin7894
      @carlfranklin7894 4 роки тому +1

      Separation. A viewmodel is a class that stands on its own. A razor.cs file is tightly coupled to the markup.

    • @ovedurak
      @ovedurak 4 роки тому

      @@carlfranklin7894 tnx for the clarification, I'm gonna think about using this technique.

  • @heinzriemann3213
    @heinzriemann3213 4 роки тому

    LOOK MA NO CODE BEHIND!
    Cracke me up good and not the only time..

  • @debeerpaul
    @debeerpaul 2 місяці тому

    Anyone using this in production?

  • @freeopinion2140
    @freeopinion2140 2 роки тому

    legend

  • @guyincognito1985
    @guyincognito1985 3 роки тому

    I worked with a Mike Easter...

  • @snapching
    @snapching 4 роки тому +2

    I thought await Task.Yield() is better than await.TaskDelay(0)

  • @BenHayat
    @BenHayat 3 роки тому +1

    Carl, shouldn't we use a DTO for a model than an Entity from the backend? This way we're not exposing a model to the client.

    • @ghevisartor6005
      @ghevisartor6005 3 роки тому

      yes now with records it's also less time consuming to create those Dtos since they are immutable. I guess it depends on how good you want to do the job lol.