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

Support default schema creation #90

Open
nhachicha opened this issue Nov 27, 2020 · 3 comments
Open

Support default schema creation #90

nhachicha opened this issue Nov 27, 2020 · 3 comments

Comments

@nhachicha
Copy link
Collaborator

Currently, we have to pass in a class annotated with RealmModule which captures some or all the models that we would like to participate in the Realm scheam. This works fines for modules and library but adds an extra step to open a Realm of you want the default behaviour that consist of using all the annotated RealmObject classes

@nhachicha nhachicha self-assigned this Nov 27, 2020
@nhachicha nhachicha mentioned this issue Nov 30, 2020
2 tasks
@sync-by-unito sync-by-unito bot changed the title Support default schema creation Support default schema creation Mar 23, 2021
@cmelchior
Copy link
Contributor

Things we need to tackle:

  1. How to locate all classes implementing RealmObject? This should also work with incremental compilation steps.
  2. How to handle that model classes might be defined in multiple modules. Relying on autogenerated code can be problematic if multiple modules write to the same location.

Some background from Realm Java

  • The annotation processor there allows us to find all Realm model classes.
  • We write these model classes to a DefaultMediator class, which was looked up using reflection at runtime.
  • Libraries are required to create a class annotated with @RealmModule. This disables the generation of a DefaultMediator and also requires that people define a RealmConfiguration.modules(...) as a way to set the schema.

This approach means that app projects work out of the box, while library modules require extra work. So far, this seems to have been a sensible tradeoff, but it is unclear if the same would work for Multiplatform where Realm primarily is used within a library module.

@nhachicha
Copy link
Collaborator Author

Also bear in mind the following compiler constraints expressed in #156 (comment)

@cmelchior
Copy link
Contributor

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

No branches or pull requests

2 participants