Blazor WebAssembly : Using HttpClient in MVVM - EP09

แชร์
ฝัง
  • เผยแพร่เมื่อ 9 พ.ย. 2024

ความคิดเห็น • 43

  • @CuriousDrive
    @CuriousDrive  4 ปีที่แล้ว +1

    Check it out - www.blazingchat.com/
    Source Code - github.com/CuriousDrive/BlazingChat
    Like, Comment and Subscribe!!!

  • @hongkyuchung5769
    @hongkyuchung5769 2 ปีที่แล้ว +2

    Awesone~~ EP07~EP09 is really good for me. Thanks!! I can understand the typical calling http procedures in client with MVVM pattern, dependency injection, Interface and httpclientfactory.

    • @CuriousDrive
      @CuriousDrive  2 ปีที่แล้ว

      Thanks for watching HongKyu. Yes there's is an easy to call APIs and then there's correct way to call APIs. I tried my best to explain that. You can learn more about them here.
      docs.microsoft.com/en-us/dotnet/architecture/microservices/implement-resilient-applications/use-httpclientfactory-to-implement-resilient-http-requests

  • @viral_plays1081
    @viral_plays1081 ปีที่แล้ว

    Loved the way you explained things, not just for Blazor but also for the OOPs concepts, along with demonstrations. It's really helpful for a beginner like me. 😊

  • @lyndondoliveiro5941
    @lyndondoliveiro5941 3 ปีที่แล้ว +1

    Very good explanation of using HttpClient in WebAssembly. Most other videos illustrate using Blazor Server

    • @CuriousDrive
      @CuriousDrive  3 ปีที่แล้ว +1

      Thanks for watching Lyndon.

  • @NemanjaSimovic
    @NemanjaSimovic 3 ปีที่แล้ว +1

    Awesome! You're the man!

    • @CuriousDrive
      @CuriousDrive  3 ปีที่แล้ว

      Thanks for watching Nemanja. Please share with your friends :)

  • @wassollderscheiss33
    @wassollderscheiss33 3 ปีที่แล้ว +1

    When you do builder.Services.AddHtppClient(...) you mention "typed Client" and "IHttpClientFactory". What do you mean be "typed client"? Isn't just a regular HttpClient hc created for DI? How does it relate to the type parameter of Implementation? Is hc only available for that implementation class? And what role has IHttpClientFactory here? If only an HttpClient is provided, where is the factory class? After all in constructor injection we get an HttpClient and not an IHttpClientFactory. Thank you for your great videos!

    • @wassollderscheiss33
      @wassollderscheiss33 3 ปีที่แล้ว +1

      I just found that, which answers my question: stackoverflow.com/questions/56390914/when-using-services-addhttpclient-where-is-the-httpclient-created
      Thanks for reading, though :-)

    • @CuriousDrive
      @CuriousDrive  3 ปีที่แล้ว

      It's fun reading all these comments. And I am glad you found the answer. Microsoft docs are very helpful. I understood the whole thing pretty quickly and how cool it is. docs.microsoft.com/en-us/dotnet/architecture/microservices/implement-resilient-applications/use-httpclientfactory-to-implement-resilient-http-requests

  • @bezimienny5
    @bezimienny5 3 ปีที่แล้ว +1

    So the constructor with injected fields is still going to be relevant even if the object instance was created using the parameterless constructor, like you did with the implicit operator? How does that work?

    • @CuriousDrive
      @CuriousDrive  3 ปีที่แล้ว

      That's a really good question. I will have to personally try that scenario but again the idea behind using implicit operator is to convert model to viewmodel and viewmodel to model. Not to use injected httpClients. I hope that makes sense. Really good question though.

  • @ricoestalilla2184
    @ricoestalilla2184 2 ปีที่แล้ว +1

    Nice tutorial for MVVM, I already use it but I have this problem with routing, how can I use/route to another page using MVVM? Thank you for answer! Have a great day!

    • @CuriousDrive
      @CuriousDrive  2 ปีที่แล้ว

      Hello Rico, thanks!!! Can you please elaborate the question? Not sure why you want to combine MVVM with routing.

  • @talkathiriify
    @talkathiriify 4 ปีที่แล้ว +1

    So Good
    Thank you very much.

    • @CuriousDrive
      @CuriousDrive  4 ปีที่แล้ว +1

      Thanks for your feedback for the last video, Tarik. I slowed it down little bit in this demo.

  • @lakshanmadubashika3248
    @lakshanmadubashika3248 ปีที่แล้ว

    could you teach us how to use repository pattern with HTTP client factory

  • @talkathiriify
    @talkathiriify 4 ปีที่แล้ว

    Dear Fahad,
    How are you, I hope you are doing well and you and your family in a good health.
    We missed you so much, so could you please kindly continue this series if you do not mind.
    Thank you so much.

    • @CuriousDrive
      @CuriousDrive  4 ปีที่แล้ว +1

      Thank you so much for your kind words Tarik. I and my family is doing well. I hope you are doing well too.
      I know I haven't been uploading videos. There are lot of things going on right now. I and my wife recently moved to a different place and been making videos for telerik too.

    • @talkathiriify
      @talkathiriify 4 ปีที่แล้ว

      I wish you all the best, and a good luck.

  • @ArunSingh-lq5fn
    @ArunSingh-lq5fn 4 ปีที่แล้ว +1

    Hi, How we manage this view model if my API is returning list object? You have created one method LoadObject to fill all data in "this". How can we use list here?

    • @CuriousDrive
      @CuriousDrive  4 ปีที่แล้ว

      Hey Arun, I would create a list property in your view-model and use foreach loop in LoadObjects to load that list.
      I hope it helps.

    • @ArunSingh-lq5fn
      @ArunSingh-lq5fn 4 ปีที่แล้ว

      Can we use Auto Mapper here?

  • @jhonpauldelvalle
    @jhonpauldelvalle 3 ปีที่แล้ว

    Thank you.

    • @CuriousDrive
      @CuriousDrive  3 ปีที่แล้ว

      You are welcome. Please it with your friends.

  • @peteroganwu951
    @peteroganwu951 4 ปีที่แล้ว +1

    Hi Fahad. I am working on a Shopping Cart application and I am using the MVVM architecture. I am using the Blazored nuget (LocalStorage) package to persist the cart item. I am getting an exception "Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100]
    Unhandled exception rendering component: Deserialization of interface types is not supported. Type 'ShoppingCartBlazorWasmMVVM.Client.ViewModels.IProductViewModel'". How do I handle this? Thanks Fahad. Other than this the application works fine.

    • @CuriousDrive
      @CuriousDrive  4 ปีที่แล้ว

      Is this ASP.NET Core hosted Blazor WebAssembly app? Make sure that you are running server as start up project. Please check this issue on GitHub - github.com/dotnet/aspnetcore/issues/22364

    • @peteroganwu951
      @peteroganwu951 4 ปีที่แล้ว

      @@CuriousDrive Yes it is Blazor WebAssembly and the Server project is the start up project.

  • @peteroganwu951
    @peteroganwu951 4 ปีที่แล้ว +2

    Hi Fahad hope all is well? It's been 2 weeks.

    • @CuriousDrive
      @CuriousDrive  4 ปีที่แล้ว

      Hello Peter, thanks for checking in. I have been making videos for telerik lately. I will be get back in making videos here soon .

  • @mariusbechtold3698
    @mariusbechtold3698 4 ปีที่แล้ว +1

    Thank you so much for this tutorial!
    When I replace builder.Services.AddSingleton(); with builder.Services.AddHttpClient
    ("BlazingChatClient", client => client.BaseAddress = new Uri(builder.HostEnvironment.BaseAddress)); it does not work anymore. When I start the Application I get an Error in the Browser. Do you have any idea, what the problem could be?

    • @CuriousDrive
      @CuriousDrive  4 ปีที่แล้ว

      Hello Marius, sorry to hear that.
      Can you please share your error message here. Maybe I will be able to help you out.

    • @ajanyhc
      @ajanyhc 4 ปีที่แล้ว

      Try this:
      cd Client
      dotnet add package Microsoft.Extensions.Http
      dotnet add package Microsoft.Extensions.Http.Polly
      cd Server
      dotnet run

    • @Antimatteryogurt
      @Antimatteryogurt 8 หลายเดือนก่อน

      I had the same problem, this fixed it for me:
      dotnet add package Microsoft.Extensions.Http --version 8.0.0