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

Nested type registries #1134

Open
wants to merge 25 commits into
base: main
Choose a base branch
from
Open

Nested type registries #1134

wants to merge 25 commits into from

Conversation

themisir
Copy link
Contributor

@themisir themisir commented Jan 5, 2023

The goal of this PR is to add nested registries to hive in order to increase typeId limit for the models.

The original implementation has been written by @xal with #804.

The final design adds the following api to the hive TypeRegistry interface (which is accessible through Hive singleton value).

Hive.registerNestedAdapters((registry) {
  registry.registerAdapter<User>(UserAdapter());
}, parentTypeId: 3);

Basically put the registerNestedAdapters method lets users to allocate a single typeId and use it for a nested type registry which can be used for registering multiple types with a single id. The nested type registry has similar characteristics as the global type registry like 256 typeId space for each nested registry, typeIds should be unique and should not be changed after being written to the disk.

xal and others added 25 commits August 13, 2021 13:33
… create NestedTypeRegistry outside from Hive package
# Conflicts:
#	hive_generator/pubspec.yaml
NestedTypeRegistry: increase type limit with backward compatibility and id overriding
Because it's out of scope of this patch
It should not be encouraged
@Mamasodikov
Copy link

Please make this possible, we are struggling!

@themisir
Copy link
Contributor Author

themisir commented Apr 9, 2023

The feature is ready, but there's some issues with web builds needs to be fixed. I will take a look when I have some free time, but can't promise any ETA.

@Mamasodikov
Copy link

The feature is ready, but there's some issues with web builds needs to be fixed. I will take a look when I have some free time, but can't promise any ETA.

I will wait for it!
In our case, it takes so much effort to convert our super (multimodule) app to any other db option. We are dependent on Hive. All we can do is increase the typeId limit. I tried to get multiple instances from hive using HiveImpl() low-level API but it doesn't work. (says "Did you forget to use openBox)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants