-
Notifications
You must be signed in to change notification settings - Fork 5
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
Added manual control possibility over holy loader #25
Conversation
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.
Reviewed my own code, lgtm!
@tomcru writing a test necessary here? Would require to set up React component testing, also dependency injection to get Otherwise ready to be reviewed and merged! |
This looks exciting and I've had something similar in mind - will test it out asap! |
So apparently it's the good ol' "it used to work but now it doesn't" scenario.. I just tested rn and it's not working anymore, will have to see what's wrong and update it here. Bugs to fix:
I'll get it sorted out soon, for now will put this in draft. |
Okay so I realised that this won't ever work on the server side because I use Anything requiring UI interactivity will forever be restricted to Client components only (which makes sense obv). That means that this functionality will too. I marked it in the documentation to make sure people know. But it definitely works now on client side now! @tomcru ready to review now! |
I was thinking the same, that'd you'd only ever use the trigger funcs to start/stop the loader in client components anyways 👍 Will review either today or tomorrow latest, thank you! |
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.
Looks and works great!
I would only suggest renaming start/stopHolyProgress
to start/stopHolyLoader
- because the HolyProgress component is not something users interact with. I think it'll be easier to remember the naming.
I noticed a little edge case where you can theoretically dispatch a ton of events which messes with the behaviour of the progress bar (I'm frantically clicking the Start button in this video) Compared to the normal behaviour: |
Co-authored-by: Tom Rumpf <[email protected]>
I think this might to be an issue related to the |
@tomcru I fixed the issue by adding a |
Maybe a simpler solution would be to update the public start = (): HolyProgress => {
if (this.status === null) {
this.setTo(0);
}
this.startTrickle();
if (this.settings.showSpinner === true) {
this.createSpinner();
}
return this;
}; to: public start = (): HolyProgress => {
if (this.status === null) {
this.setTo(0);
this.startTrickle();
if (this.settings.showSpinner === true) {
this.createSpinner();
}
}
return this;
}; As a result, incrementing is only started if it's a new progress bar - and not if it is already running. This works on my side, can you possibly confirm this also works in your use case? |
c184497
to
a873138
Compare
@tomcru works like a charm! Pushed the solution right now as well :) |
Thank you! good stuff 🔥 |
@tomcru been testing this yesterday throughout my platform, it works insanely well. Very happy with the results and good UX addition. |
Description
I've had a few instances where I needed to trigger the holy loader manually (eg. because of an async operation), but I couldn't because the possibility wasn't there. So I added two new functions (
startHolyProgress
andstopHolyProgress
) to control the holy loader manually. Simple yet very useful.Concretely what was done:
React.useRef
because usinglet
is not best practice. It's important to keep the same reference to the HolyLoader object, using alet
does not guarantee this. Aref
is the correct method. (let
actually caused a bug when I was trying tostopProgress
which would fire butholyLoader.complete()
didn't do anything!)startHolyProgress
andstopHolyProgress
to control the holy loader manually using custom events, meaning you can only use these in Client components!sppeed
->speed
)Type of change
Please delete options that are not relevant.
React.useRef
usageChecklist: