react-countdown icon indicating copy to clipboard operation
react-countdown copied to clipboard

Invoke oncomplete if date has passed

Open bendikjohansen opened this issue 2 years ago • 2 comments

As discussed in #169, it could be helpful to invoke the onComplete callback if the provided date has passed by the time the Countdown component has been initialized. Per @ndresx's suggestion in the mentioned issue, the callback is now being invoked with a second argument to specify whether this is the case or not.

Please let me know if you have any feedback; I'll be happy to amend the code.

bendikjohansen avatar May 08 '22 13:05 bendikjohansen

Coverage Status

Coverage remained the same at 100.0% when pulling 4bca3e88160e668d76fd4c55cf21e7da0b78209c on bendikjohansen:invoke-oncomplete-if-date-is-passed into a7185be64596dac04d3b31fe25f59ff6c6b1d1ce on ndresx:master.

coveralls avatar May 08 '22 15:05 coveralls

Thank you for the feedback!

That sounds like a good idea. I was worried about having to change the countdown status of the component so it isn't stuck in started even though onComplete has been invoked. Do you have any thoughts about this?

I'm having some issues with running the nested example project and the linting script, but the tests seem to run fine. I'll push the changes once I figure this out :-)

bendikjohansen avatar May 08 '22 16:05 bendikjohansen

@bendikjohansen It has been a while since you proposed this change; sorry for not responding sooner. I've made more changes to it and finally got to merge it.

Thank you for taking the time to work on this. Have a nice day!

ndresx avatar Oct 22 '22 13:10 ndresx

This was actually a breaking change, as before this change onComplete also supported being passed a type () => Promise<void>, which is no longer the case.

stefanofa avatar Nov 22 '22 12:11 stefanofa

@stefanofa This should be possible again with https://github.com/ndresx/react-countdown/releases/tag/v2.3.5.

ndresx avatar Nov 23 '22 21:11 ndresx