firebase-database-dotnet icon indicating copy to clipboard operation
firebase-database-dotnet copied to clipboard

Push all Changes from offline RealtimeDatabase to online DB

Open Phil4121 opened this issue 3 years ago • 1 comments

I'm facing the problem that I've got multiple "childs" which can be created in offline mode by the user.

In my MAUI App I am using dependency injection and my implementation looks like this:

MauiProgram.cs

        DependencyService.Register<IDataService<ABC>, ABCService>();
        DependencyService.Register<IDataService<DEF>, DEFService>();

ABCViewModel.cs

    private IDataService<ABCModel> DataService { get; }
        DataService = DependencyService.Resolve<IDataService<ABCModel>>();

FirebaseDataService.cs

    public abstract class FirebaseDataServiceBase<T> : IDataService<T> where T : class
    {
        private readonly RealtimeDatabase<T> _realtimeDb;

        public RealtimeDatabase<T> RealtimeDatabase => _realtimeDb;

        private FirebaseClient client;
        
        public FirebaseDataServiceBase()
        
            client = new FirebaseClient("https://....",
                new FirebaseOptions
                {
                    OfflineDatabaseFactory = (t, s) => new OfflineDatabase(t, s)
                });

            _realtimeDb = client
                .Child("ABCDataTable)
                .AsRealtimeDatabase<T>("", "", StreamingOptions.LatestOnly, InitialPullStrategy.MissingOnly, true);
        }

      .....
    }

Store the data in my offline DB works well! Thanks therefor to everyone who is involved in this project!!!!

Also to sync the changes to the online DB works great! The problem is, that due the Dependency Injection the user has to visit for example the ABCPage so the DataService in the ABCViewModel is instantiated and after that, offline changes are synct to the online DB.

So my question is, is there a possibility to sync all changes - no matter what "child" and type - with one call?

Thanks!

Phil4121 avatar Jan 02 '22 19:01 Phil4121

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Jul 31 '22 08:07 stale[bot]

Closing the issue due to inactivity. Feel free to re-open

stale[bot] avatar Sep 21 '22 03:09 stale[bot]