-
Notifications
You must be signed in to change notification settings - Fork 389
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
New data written to the disk is not immediately available. #1278
Comments
Similar issue I am facing too and is especially occurring with nested data for me like if I am saving a data model after fetching from the API, I believe this is due to the async nature of the package. What I am planning to do now is save data using a different way. Previously-
final hiveBox =
HiveService.getBox<LoginModelData>(HiveService.loginModelDataBox)
..put(HiveService.loginModelDataKey, dataModel.data!);
accessed like this - HiveService.userBoxKey?.teacherId,
now I've to follow the old method in my other apps which I now believe is the sane way. static Box<LoginModelData> userBox =
Hive.box<LoginModelData>(name: loginModelDataBox);
static int get teacherId {
if (userBox.containsKey(JsonKeys.teacherId)) {
return userBox.get(JsonKeys.teacherId)!.teacherId ?? 0;
} else {
return 0;
}
}
static set teacherId(int id) {
if (userBox.containsKey(JsonKeys.teacherId)) {
userBox.put(
JsonKeys.teacherId,
LoginModelData(teacherId: id),
);
} else {
userBox.put(
JsonKeys.teacherId,
LoginModelData(teacherId: id),
);
}
}
set it this way - HiveService.teacherId = dataModel.data!.teacherId!;
access it this way - body: {
JsonKeys.userId: HiveService.teacherId,}
I believe there would be better ways to handle this issue. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have a scenario where user can open multiple browser tabs/sessions which could write data to our Hive Boxes. Currently the API for a box provides a
values
which allows the app to get the data for a box. However, the data added to a box by one browser tab is not immediately available in the same box in another browser tab/session.Does Hive support something like this?
Thanks in Advance!
The text was updated successfully, but these errors were encountered: