-
Notifications
You must be signed in to change notification settings - Fork 352
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
Refactor Manager #3062
Refactor Manager #3062
Conversation
refactor: More descriptive name for manager callbacks
fix: Manager API extends Selectable
It turns out, this wasn't a bug after all This reverts commit a235438.
72e39eb
to
57a558e
Compare
@simolus3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I agree that the full names for the type arguments make the manager code much easier to grasp (and the new companion typedef names are also clearer). I don't think we need to rebase/clean up the history.
Revisiting the code, I'm not quite sure what justifies having ProcessedTableManager
as a separate class right now, is this required for references or another feature you have in mind that would be breaking without it?
@simolus3 |
Thanks for the quick follow-up and the detailed explanation! I'll check them tomorrow, I wanted to get the docs update for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, this looks good to me now!
We have 2 ways to proceed for a Option 1: Wrap the Class // Implementation
class UserWithReferences {
UserWithReferences(this.user)
final User user;
final GroupManager get group => GroupManager(...).filter(...);
}
// Usage
final usersWithRefs = await users.withReferences(...).get()
for (var userWithRefs in usersWithRefs){
final user = userWithRefs.user;
final group = await userWithRefs.group.getSingle()
} Pros
Cons
Option 2: Extend the Class// Implementation
class UserWithReferences extends User{
UserWithReferences(
super.name,
super.age,
super.gender,
/// ... and all the other fields
)
final GroupManager get groupManager => GroupManager(...).filter(...);
}
// Usage
final users = await users.withReferences(...).get()
for (var user in users ){
// final user = userWithRefs.user; NOT NEEDED
final group = await user.groupManager.getSingle()
}
Pros
Cons
What are your thoughts? |
This PR does the following:
drift_flutter
branch$Table
instead ofT
)ManagerState
_getChildManagerBuilder
)I will create the next PR once this is merged.
NOTE: I "fixed" a "bug" and then reverted it.
Lmk if I should go back and undo the commits so we should have a cleaner git history.
I want to make this as painless for you as possible.
The next feature (references) will introduce another level of complexity and I don't want to be the only person with a strong understanding of it.
I'll be documenting the next PR very clearly.
I'm looking for constructive criticism if you ever have any for me.