You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
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.
staticBox<LoginModelData> userBox =Hive.box<LoginModelData>(name: loginModelDataBox);
staticintget teacherId {
if (userBox.containsKey(JsonKeys.teacherId)) {
return userBox.get(JsonKeys.teacherId)!.teacherId ??0;
} else {
return0;
}
}
staticsetteacherId(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.
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: