Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lazy boxes, Multiple boxes, Watch grammatically? #115

Closed
uwejan opened this issue Nov 4, 2019 · 3 comments
Closed

Lazy boxes, Multiple boxes, Watch grammatically? #115

uwejan opened this issue Nov 4, 2019 · 3 comments
Labels
question Further information is requested

Comments

@uwejan
Copy link

uwejan commented Nov 4, 2019

Question
Hello there, what is the equivalent to WatchBoxBuilder, in order to get the current values and updates events?
I am planing to use flutter_bloc as for managing state, and wish to get the data and updates throught the bloc events and state. i tried calling watch() method on a box on my bloc but that would only get the activities plus values of it, but not the already stored values.

second question, my app would store messages in many other boxes, will that be an issue on ram? say 10 boxes, with each 1000 entry?

third question, my understanding after reading docs, is that if i have many boxes and do not want to put more data into memory, i should use lazy boxes instead, but i got the error, [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: HiveError: Lazy boxes do not support type arguments.
i could open the box without specifying type, but that will not allow me to use WatchBoxBuilder, so in order to get the best of boxes and mainataine clean code and performance what should i do please?

Version

  • Platform: android.
  • Flutter version: latest
  • Hive version: latest
@uwejan uwejan added the question Further information is requested label Nov 4, 2019
@simc
Copy link
Member

simc commented Nov 4, 2019

I am planing to use flutter_bloc as for managing state, and wish to get the data and updates throught the bloc events and state. i tried calling watch() method on a box on my bloc but that would only get the activities plus values of it, but not the already stored values.

I think this is related to #20. I'm not sure if it is something Hive needs to provide because it is very bloc specific and you can do it easily yourself using the box.watch() method.

second question, my app would store messages in many other boxes, will that be an issue on ram? say 10 boxes, with each 1000 entry?

This depends on the size of your messages. I would say it is still okay to have this amount of messages in RAM but it should not be much more. Consider using lazy boxes as an alternative.

i could open the box without specifying type, but that will not allow me to use WatchBoxBuilder, so in order to get the best of boxes and mainataine clean code and performance what should i do please?

Yes, like the error says, you cannot use type arguments for lazy boxes. This has nothing to do with the WatchBoxBuilder and it should work as always.

@uwejan
Copy link
Author

uwejan commented Nov 5, 2019 via email

@simc
Copy link
Member

simc commented Jan 3, 2020

WatchBoxBuilder has been deprecated. You can use box.listenable() or create an extension method which fits your needs.

@simc simc closed this as completed Jan 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants