vuex-easy-firestore icon indicating copy to clipboard operation
vuex-easy-firestore copied to clipboard

Lazy loading modules / Limit the number of module instances

Open JasonAlanKennedy opened this issue 6 years ago • 11 comments

A quick question; How can one lazy load a easy firestore module? and not load everything in all at once?

JasonAlanKennedy avatar Feb 18 '19 03:02 JasonAlanKennedy

It depends on what you mean with lazy loading the module.

If you mean for Firestore data, you can just refrain from executing openDBChannel or fetchAndAdd.

If you mean adding a Vuex easy Firestore module dynamically after the store is already instantiated: this is not recommended for Vuex plugins, but could be done I think. It is quite hacky though. But then again, I don't think there's any use case for this because there's not much benefit from doing so.

--
Vuex Easy Firestore was made with ♥ by Luca Ban.
If this library helped you in any way you can support me by buying me a cup of coffee.

mesqueeb avatar Feb 18 '19 03:02 mesqueeb

We didn't think so. Imagine loading hundreds of stores during the initial download on a mobile device - that's why you register Vuex modules only when they are needed.

JasonAlanKennedy avatar Feb 18 '19 03:02 JasonAlanKennedy

Oh! I never imagined a use case where you need hundreds of stores! XD I personally only need to use about 3-6 Vuex modules each app I make.

Could you explain a little more about your use case? Then I can think if I should integrate dynamic module creation or not.

--
Vuex Easy Firestore was made with ♥ by Luca Ban.
If this library helped you in any way you can support me by buying me a cup of coffee.

mesqueeb avatar Feb 18 '19 04:02 mesqueeb

@mesqueeb Maybe I need this feature. My problem is to load (in App startup) an App configuration settings that explain which firestore collection is needed. So i need to load my App_config document and then load App Data based on app_config param. Is this the case?

stegithub avatar Mar 19 '19 16:03 stegithub

@stegithub Hi! Thanks for your message.

If you need to load different collections based on this "app config" you can just use pathVariables. Will this not be enough for your needs? Let me know! 🌝

mesqueeb avatar Mar 19 '19 22:03 mesqueeb

@mesqueeb yes, thanks, for this UC is correct to use pathVariables. Totally confused :)

stegithub avatar Mar 20 '19 15:03 stegithub

I also need lazy load of the modules to load the data only when it's needed.

And I'm wondering if I call openDBChannel multiple times on the same path, will this introduce any issues with the library?

The use case for that might be like that: to call openDBChannel only if user navigates to a specific page in the app - the data will be loaded for the first time at that point. And when the user comes back to that same page later, the openDBChannel will be called again but the data will be read from the already opened connection since it's already running (unless it was disconnected for whatever reason, which will reconnect it in this case).

arthabus avatar Jul 27 '19 10:07 arthabus

ok, found an answer in other issues that openDBChannel will throw an error if there is an already opened connection.

arthabus avatar Jul 27 '19 10:07 arthabus


After about two years of open source, I finally got accepted for Github Sponsors!

💜 github.com/sponsors/mesqueeb 💜

A little about me:

  • I love open-source
  • 6 months ago I got a son, and am trying to be an awesome father 😅
  • I'm doing freelance work here and there as my main job

If anyone was helped with vuex-easy-firestore, I'd greatly appreciate any support!

BTW, donations get's paid DOUBLE by GitHub! (they're alchemists... 🦾)

Going forward 👨🏼‍💻

  • I got great plans for the future of vuex-easy-firestore going above and beyond!! Look forward to it!!
  • On to many more years of open-sourcing! 🎉

mesqueeb avatar Nov 25 '19 05:11 mesqueeb

I've read messages in this thread and I think that either I misunderstood, or people are confusing "module" for "document". I doubt anyone would ever need hundreds of stores or hundreds of collections, and unretrieved documents consume zero resource. Could someone please provide a more complete description of the need please? Otherwise I think this thread can be closed.

louisameline avatar Dec 05 '19 17:12 louisameline

I guess we could have a "readonly" option on a collection, and we'd re-use a single module to load all required documents. It would consume less memory, but the documents couldn't be interacted with (no patch, delete, etc.). I will leave this open, with low priority. Feedback is always welcome if I missed something. Thank you.

louisameline avatar Dec 06 '19 12:12 louisameline