-
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Add a base model which entity models inherit from #44
Comments
This is gonna be a little tougher than I thought:
I don't think the code I've written is incorrect: import { BaseCollection } from './BaseCollection'
class TodoCollection extends BaseCollection {
// Constructor
constructor() {
super('todos')
}
}
export { TodoCollection } Could be related to: vitejs/vite#9703 There's a workaround suggested here. Don't love implementing "workarounds". |
Likely a case of circular dependencies...
|
Dependencies were already circular before this. I don't know why now that I've made one simple change it's a problem all of a sudden. 🤷♂️ |
I've managed to fix the issue outside of the testing suite, which is promising. So now if I can just fix whatever's wrong with the tests... |
A while back, I discussed the desire to move the initStore functions to the components that require them. I've just added the basic functionality that should allow this. A Now if I can just move all of the In fact, this is what managed to restore functionality to the main app. The test suite complains because I'm still initialising stores manually there... the workaround for which is what? The stores do need to be initialised in order to test their behaviours. The stores do require the |
Take ActiveInterval.spec.ts for example: beforeEach(() => {
// TODO: We should probably createTestingPinia and setup mocks of internal actions
setActivePinia(createPinia())
useIntervalsStore().initStore()
useTodosStore().initStore()
}) It's initialising both the intervals store and the todo store. These each call their respective collection ( So if we remove those store references from Worth a test. Quickest way to check is to put the init logic in... probably not |
That works!! Will create a PR soon... _clearly gonna have a lot more scope than I would have liked, but I'll try to organise the commits into sensible, smaller steps. |
As is, Interval, Tally, Comment and even Todo models share a bunch of common setup. And IntervalCollection, TallyCollection, CommentCollection and TodoCollection are practically identical (though if they are reduced to a common model, it should accept a parameter for uniqueness and indices setup on individual types).
Reduce code repetition by setting up a base model which the above models inherit from. Extend the base model on specific models with only what is unique to them, significantly reducing repetition and improving readability of individual classes.
The text was updated successfully, but these errors were encountered: