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

Model inheritance #46

Merged
merged 9 commits into from
May 24, 2023
Merged

Model inheritance #46

merged 9 commits into from
May 24, 2023

Conversation

thombruce
Copy link
Owner

closes #44

@github-actions
Copy link

github-actions bot commented May 24, 2023

Coverage Summary for `./packages/web`

Status Category Percentage Covered / Total
🟢 Lines 94.35% / 60% 719 / 762
🟢 Statements 94.35% / 60% 719 / 762
🟢 Functions 72.5% / 60% 58 / 80
🟢 Branches 89.32% / 60% 92 / 103
File Coverage
File Stmts % Branch % Funcs % Lines Uncovered Lines
packages/web/src/components/ActiveInterval.vue 100% 100% 100% 100%
packages/web/src/components/CommentCount.vue 95.45% 100% 50% 95.45% 19
packages/web/src/components/IntervalTimer.vue 73.52% 25% 20% 73.52% 17-19, 22-27
packages/web/src/components/StaticInterval.vue 100% 100% 100% 100%
packages/web/src/components/TallyCounter.vue 100% 100% 50% 100%
packages/web/src/components/TodoItem.vue 90.56% 75% 42.85% 90.56% 15-17, 28, 32
packages/web/src/components/TodoList.vue 87.5% 100% 33.33% 87.5% 10, 16-18
packages/web/src/models/Base.ts 94.52% 100% 81.81% 94.52% 34-35, 55-56
packages/web/src/models/BaseCollection.ts 100% 100% 100% 100%
packages/web/src/models/Comment.ts 94.73% 100% 66.66% 94.73% 32-33
packages/web/src/models/CommentCollection.ts 100% 100% 100% 100%
packages/web/src/models/Interval.ts 100% 75% 100% 100%
packages/web/src/models/IntervalCollection.ts 100% 100% 100% 100%
packages/web/src/models/Tally.ts 94.73% 100% 66.66% 94.73% 32-33
packages/web/src/models/TallyCollection.ts 100% 100% 100% 100%
packages/web/src/models/Todo.ts 92.5% 90.9% 66.66% 92.5% 41-42, 45-46, 49-50
packages/web/src/models/TodoCollection.ts 100% 100% 100% 100%
packages/web/src/plugins/loki.ts 100% 100% 100% 100%
packages/web/src/plugins/pinia.ts 100% 100% 100% 100%
packages/web/src/plugins/timepiece.ts 71.42% 60% 50% 71.42% 14-19
packages/web/src/stores/comments.ts 97.29% 100% 100% 97.29% 15
packages/web/src/stores/globals.ts 100% 100% 100% 100%
packages/web/src/stores/intervals.ts 98.14% 100% 100% 98.14% 18
packages/web/src/stores/tallies.ts 97.5% 100% 100% 97.5% 16
packages/web/src/stores/todos.ts 97.56% 100% 100% 97.56% 15

@thombruce thombruce marked this pull request as ready for review May 24, 2023 02:25
@thombruce
Copy link
Owner Author

  • Tidy up index.vue and _todo.vue (we don't need all of the stores to be initialised here)
  1. Ensure that initStore actions check for presence and non-emptiness of list state, so that on page visits it isn't refreshed each initStore()
  2. initStore() for specific stores as needed, on highest level components which require them

Intervals and Tallies aren't always going to be needed, for example. At present, they are, but we intend to allow for the end user to configure this per-todo. Initialise the respective stores on the components which require them or... at first invocation of useSomeStore(). Is that possible?

@thombruce
Copy link
Owner Author

thombruce commented May 24, 2023

No lifecycle hooks or anything to tap into in terms of triggering an action on initial store invocation.

I could do something like... wrap useSomeStore() in my own function which does something like:

() => {
  const store = useMyStore()
  store.initStore()
  return store
}

Or... now that I know the database is certain to be loaded before any store module is called (outside of tests, anyway), maybe I could:

  // State
  const list = ref(new MyCollection() as Collection)

  // Actions
  function initStore() {
    // list.value = new TodoCollection() as Collection
  }

It should be equivalent.

Tests are succeeding when I modify the todos store to behave that way. The initStore() headaches might just be a thing of the past...

@thombruce
Copy link
Owner Author

I've done that for all stores now, and it is working both in tests and in the browser. However... removing initStore() entirely is a slightly bigger job than the cleanup I wanted to do, so I am going to merge as is and setup another issue to handle the complete removal of initStore() functions now that they aren't necessary.

@thombruce thombruce merged commit b500d36 into main May 24, 2023
@thombruce thombruce deleted the feat/model-inheritance branch May 24, 2023 02:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Add a base model which entity models inherit from
1 participant