snamiki1212 / plangoab

Immigration schedule planner with Next.js, Redux, and FullCalendar.js
https://plangoab.snamiki1212.com
GNU General Public License v3.0
9 stars 0 forks source link

Refactor to split data model that user-profile-story and created-story #50

Closed snamiki1212 closed 3 years ago

snamiki1212 commented 3 years ago

Split data model in redux store

// data model

// before
calendar:
  stories: [userProfileStory, ...myCustomStories]

// after
calendar:
  stories: [...myCustomStories]
userProfileStory:
  story: <data-here>

// when to select this data
// combine [userProfileStory.story.data, ...calendar.stories] to use re-select

Advantage

vercel[bot] commented 3 years ago

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/snamiki1212/plangoab/HwE6Lrbk4RJTeiEzGb4P1dqptQvR
✅ Preview: https://plangoab-git-refactor-split-user-story-snamiki1212.vercel.app

snamiki1212 commented 3 years ago

Through developing, I know some problems this model.

complexity

deps relation become more simple but data model become more complex. so need to use reselect to select combine data

obj has calendarId

Now some objects have calendar-Id even if it's not smart from the perspective of normalization. because this is FullCalendar's constraint. we need some callback for fullcalendar but sometimes it's difficult to select parent model ID from child.

but in this PR, this new userProfileStory doesn't have calendarId so we need 2 types of data modal. especially this custom data model would not be added property but omitted propery(calendarId). so this data model makes more complex conditions when to use some basic function.


eventually, I'm thinking we do not change data model but try to change UX workflow