drualcman / BlasorIndexedDb

Manage indexedDb from c# with Blazor
GNU Lesser General Public License v3.0
8 stars 3 forks source link

Add support to MAUI Hybrid Apps #2

Open pablo-daza-incontact opened 11 months ago

pablo-daza-incontact commented 11 months ago

It would be great to add support of MAUI

    public static async Task<MauiApp> UseBlazorIndexedDbContext<TContext>(this MauiApp app) where TContext : StoreContext<TContext>
    {
        StoreContext<TContext> context = app.Services.GetRequiredService<TContext>();
        await context.Init();
        return app;
    }
pablo-daza-incontact commented 11 months ago

there is also incompatibility because the following error image it will be necessary to add some handler to execute the code from MAIN.razor file in hybrid applications

I found a workaround adding the following method at Main.razor

image

image

drualcman commented 11 months ago

Thanks for your comment. Initially is thinked to use in Blazor Apps. I don't have too much experience in MAUI, but soon i will start to work with MAUI so maybe I will work on that.

But if you have experience, it's good if you folk this repository and contribute to add that positibilir.

Reminder, IndexedDb it's is a database in the Browsers, so I am not sure about the posibility to access in a Android or Ios device, sure in Windows is not. So, maybe you must eb to implement in a Hibrid and not in a MauiApp.

If you are using the hybrid I guess should eb work. I will try to reproduce and keep you updated.

drualcman commented 6 months ago

We removed and improved how to load database. Now no need to initialized from the app start. Please update to last version and try again. While you are using Razor components must be work.

drualcman commented 3 months ago

Reminder from version 1.6.32 we not longer need to todo the Init in the startup.

Also check releases 1.6.35 and release 1.6.37. In this last version 1.6.37 you can see only need to use the await.Init() if you drop the database to create again the database from code. Like is corrupted and need to reset.

I did a small test in MAUI and using WebView and Razor Library with all dependences I can't found any issue in the last versions.

Also to manage the IndexedDb correctly, remind to use in OnAfterRender, not in OnInitialize event, because IJsRuntime not always it's available in the OnInitialize, for example, if the App it's first time load, or user refresh page. But If app it's already working then you can use OnInitialize to start work with IndexedDb. This is relative how Blazor manage the DOM, it's not about our library.