-
Notifications
You must be signed in to change notification settings - Fork 27
refactor: visibility observer #74
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
base: master
Are you sure you want to change the base?
refactor: visibility observer #74
Conversation
b130407
to
5268ad7
Compare
5268ad7
to
6de5892
Compare
6de5892
to
c665207
Compare
@timowolf Could you please review this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@chintankavathia thanks a lot for the MR 🙇
Just one question from my end, the implementation itself looks a-ok from my end.
/** | ||
* Throttle time in ms. Will recalculate table this time after the resize. | ||
*/ | ||
@Input() resizeThrottle = 100; | ||
|
||
/** | ||
* Emits first visibility change immediately without waiting for resizeThrottle. | ||
*/ | ||
@Input() emitInitial = true; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the current/new behavior is not filled in within the MR template, would you mind commenting on why we should expose those values? I'm personally afraid that this just leads to non-aligned behavior across users and starts introducing issues. The input description also doesn't guide users to what values they should exactly use. I would therefore just pick sane defaults and not yet expose them to the end user, doing so only after we have a concrete need.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fh1ch currently we have siResizeObserver
as part of our internal Element lib which is being used with datatable by consumers manually to trigger recalculate (people often forgets to do this and end up with issues). Goal of the MR is to remove that manual need however since siResizeObserver
also allows these two props I am exposing the same here to keep it compatible with what we have today with siResizeObserver
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@chintankavathia thanks a lot for the reply 🙇
@spike-rabbit thanks also for your comment. I do agree that we should probably wait with this one a bit, so we can address the resize events holistically. To quickly outline my concerns with the current approach:
- Consumers had to handle the resize event on their own so far and trigger the recalculation "manually". If we now suddenly handle this internally we create two trigger sources, which can be problematic if we consider performance. I therefore think this should be treated as a breaking change, so consumers are aware of it and can remove the overhead code on their end.
- Even if the internal
siResizeObserver
directive did offer inputs likeresizeThrottle
andemitInitial
, I don't think that we need API compatibility since users anyway have to manually migrate (see point 1) and they also don't really make a lot of sense in the context of the datatable (especially the later).
Hence my point that we probably shouldn't integrate them from the get-go. Feel free to share your opinion here, but as said by @spike-rabbit, we can also discuss this once we rework the resize events all-together.
use `ResizeObserver` api to emit visibility change. Also auto recalculate table when table resize by parent containers.
c665207
to
5111072
Compare
I would like to postpone this for a while. I see chances, that we may can get rid of listening to resize events completely. |
use
ResizeObserver
api to emit visibility change. Also auto recalculate table when table resize by parent containers.What kind of change does this PR introduce? (check one with "x")
What is the current behavior? (You can also link to an open issue here)
What is the new behavior?
Does this PR introduce a breaking change? (check one with "x")
If this PR contains a breaking change, please describe the impact and migration path for existing applications: ...
Other information: