I want to write a simple website that connects to github api to manage issue CRUD
There will be 3 screens
List of repositories (as links)
List of issues in a selected repo
Issue content once navigated through the hirarchy
my question is as follows
If I only have one giant state object
that saves all things
how would I go about when for example I selected a Repo and want to display the issue list view
would I check in the render method if issue list is populated then do not render repo list but instead render issue list
Is there a pattern one could use that makes this a little clearer and simpler
Mikael Brevik
@mikaelbr
hi, @nomad5000! Given that I understand your problem correctly, first of all. This data can be lazy
So you can start by having just repo, and when you press one you fetch ajax content and set a list of issues to that repository.
And when you press that issue, either if you have the content of that issue from before (through your first AJAX request) you can mark it as “selected” (change the state of that issue in the global state to have a flag saying “selected”) and then in the render function of where you want to show the content, you go through the list and show the one issue that has the selected flag
or you can copy the structure to a selected property on the top of your global state if you want that
If the issue content data is lazy the latter example is also what you’d do. Similarly to how I explained the repo -> issue fetching process
nomad5000
@nomad5000
@mikaelbr Thank you. I looked at the TodoList example and I think it explains a lot. Also I watched the video on the omnicient site. It helped me understand the concept, and the advantage of a tree like state. I was having trouble with the idea to save display logic in a state object (show: RepoList, IssueList, SelectedIssue). Now I understand the concept better. I was just worried that an increasing number of diferent screens makes the state object so complex that it gets hard to handle
Peter Boyer
@pboyer
Hey, I might have missed this, but has anyone put any thought into a statically typed version of this API?
Mikael Brevik
@mikaelbr
@pboyer I started rewriting in TS and testet out flow last year, but didn't finish it. So as far as I know, nothing exists.
I know of someone using TS with Omniscient, but I don't know if any type definitions are online/public