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

**Feature:** TopbarSelect hooks #943

Merged
merged 14 commits into from
Mar 11, 2019

Conversation

JoshRosenstein
Copy link
Contributor

Summary

  • Added useEventListener
  • Added useDebouncedCallback (replaced lodash/debounce)
  • Added useDebounce (not used in module, but maybe good for any autocomplete or fetching state )

Related issue

910

To be tested

Me

  • No error or warning in the console on localhost:6060

Tester 1

  • Things look good on the demo.

Tester 2

  • Things look good on the demo.

Copy link
Contributor

@TejasQ TejasQ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I absolutely love the decentralized approach you've taken using custom hooks for debounce and event handling. 😍

If we can type these a bit stronger and fill in the READMEs, this would be an incredible contribution to the library.

src/TopbarSelect/TopbarSelect.tsx Outdated Show resolved Hide resolved
src/useDebouncedCallback/index.ts Outdated Show resolved Hide resolved
src/useDebouncedCallback/index.ts Outdated Show resolved Hide resolved
src/useDebouncedCallback/index.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@TejasQ TejasQ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's make things a little more approachable.

src/useDebounce/README.md Outdated Show resolved Hide resolved
src/useDebounce/README.md Outdated Show resolved Hide resolved
Copy link
Contributor

@mpotomin mpotomin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add some clarification and documentation please. 🙌

src/useDebounce/README.md Outdated Show resolved Hide resolved
src/useDebouncedCallback/index.ts Outdated Show resolved Hide resolved
src/useWindowEventListener/README.md Outdated Show resolved Hide resolved
Originally, i created the hooks to mimic the original code, however, now i question if the original implentation to capture window resize and use of debounce was even necessary.
@JoshRosenstein
Copy link
Contributor Author

@TejasQ @mpotomin @stereobooster - After testing TopbarSelect- using the example in TopBar readme, on dev-server, I caught a bug where the width was not getting passed to the ContextMenu, unless the window got resized. After playing around with it, I came to the conclusion that its unnecessary, to check the width on window resize. So i removed the hooks. If you agree that these methods are not needed, please let me know if I should remove all 3 of the new hooks from this PR, or not.

src/useWindowEventListener/index.ts Outdated Show resolved Hide resolved
src/useWindowEventListener/index.ts Outdated Show resolved Hide resolved
src/useDebounce/README.md Outdated Show resolved Hide resolved
src/useDebounce/README.md Outdated Show resolved Hide resolved
src/useDebouncedCallback/README.md Outdated Show resolved Hide resolved
src/useDebouncedCallback/README.md Outdated Show resolved Hide resolved
src/useDebouncedCallback/index.ts Outdated Show resolved Hide resolved
src/useWindowEventListener/index.ts Outdated Show resolved Hide resolved
@TejasQ
Copy link
Contributor

TejasQ commented Mar 5, 2019

@JoshRosenstein

please let me know if I should remove all 3 of the new hooks from this PR, or not.

It's tricky because:

  1. We would rather your work not go to waste, so let's keep them, but
  2. Less is always more/better in code.

Let's remove them. We still have the individual commits that add them in case we need them later. 😄

Copy link
Contributor

@TejasQ TejasQ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@stereobooster wanna have a look?

@TejasQ TejasQ requested review from mpotomin and stereobooster March 6, 2019 16:13
Copy link
Contributor

@TejasQ TejasQ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job, @JoshRosenstein 🎉 !

src/TopbarSelect/TopbarSelect.tsx Show resolved Hide resolved
@TejasQ TejasQ merged commit 1d6ef28 into contiamo:master Mar 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants