to track or not to track
See original GitHub issuehi guys
i came across a use case where pausing and resuming the tracking of state paths would be beneficial.
usecase
imagine a table with multiple rows which supports the following features (simplified for now):
- sorting
- inplace editing of the cells
now imagine we have the following table sorted by column Name
:
Id Name
1 Anthony
2 Beat
lets say our state that holds the rows looks like:
myRows:
{
1:{Id:1,Name:"Anthony"},
2: {Id:2, Name:"Beat"
}
after rendering the tracked paths will contain:
myRows.1
myRows.1.Name
myRows.2
myRows.2.Name
(because the sorting method accessed those paths)
now inplace editing the table to:
Id Name
1 Christian
2 Beat
will result in the table to be immediately flipped over to:
Id Name
2 Beat
1 Christian
because of the sorting
This is not a good user experience. What i would like is that the sorting just happens after explicitly clicking on the column header and not right after editing a cell.
if i now could something like
app.pauseTracking()
dotheSortingThingy()
app.resumeTracking()
those paths wouldn’t be tracked and my use case would be fine 😃
Issue Analytics
- State:
- Created 5 years ago
- Comments:9 (9 by maintainers)
Top GitHub Comments
Hi 👋
About the proposal
I don’t think this is a good idea, mainly for two reasons:
1 - Path tracking is an implementation details
The notion of Path Tracking is not something the user (user === dev using overmind) is supposed to know about, it’s how we do it but not how we present it to the user.
2 - This could lead to serious bug way too easily
What if the user forget to call
resumeTracking
? What if you use a library and call some of it’s stuff while the path tracking is paused ?About the use case
IMO, you are using the wrong state here. Either you decide that your rows are sorted by name (with a
currentSortCriteria
state), in that case they are sorted at all time (and I agree with you it’s not a great UX when the user update something), or you want the re-order to happend only when the user click the header and in that case you need an state that store the order of the row and not the criteria.So in my opinion the simplest solution to this is to add a
order
state that would store the order of the colum at any point in time. Then clicking on a column header would update thatorder
state using the values when the user clicked and this state would not change until the user click on another header.Just for completeness sake. I have an action now which creates the new sorted rows (ids) whenever a user changed the filter or whenever the user changes the sorting. this sorted rows is also saved in state giving nice insights using devtools. the components just point to this sorted rows and just update fine now when the user really is requesting it.