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

[FEAT] - Callback and timeout #49

Closed
vfrz opened this issue Mar 18, 2022 · 1 comment
Closed

[FEAT] - Callback and timeout #49

vfrz opened this issue Mar 18, 2022 · 1 comment
Assignees
Labels
done Done enhancement New feature or request

Comments

@vfrz
Copy link

vfrz commented Mar 18, 2022

Is your feature request related to a problem? Please describe.

I wanted a notification with a timeout and a callback.

Describe the solution you'd like

I'd like to have the possibility to have a timeout and a callback together.

Additional context

It is currently not possible because of this line which prevent the timeout if callback is set: https://github.com/notiflix/Notiflix/blob/main/src/notiflix.js#L769

If you are okay with this, I can try to make a PR!

@vfrz vfrz added the enhancement New feature or request label Mar 18, 2022
@furcan
Copy link
Collaborator

furcan commented Mar 19, 2022

Hi @vfrz,

"The notifications with the callback function do not disappear until they were clicked."
https://notiflix.github.io/notify

So, it will be going to stay as it is. For your expectation; you can use your own solutions. For instance, an example of usage can be as below. (In addition, it is not related to the line(code) that you have mentioned.)

// example
var yourExpectationNotifySuccess = function (message, callback) {
  var yourTimeoutExpectation = 1923;
  Notiflix.Notify.success(message, {
    timeout: yourTimeoutExpectation,
  });
  
  var delay = setTimeout(function() {
    callback();
    clearTimeout(delay);
  }, yourTimeoutExpectation); 
};

// usage
yourExpectationNotifySuccess('Sol lucet omnibus', function () {
  // your callback codes...
  console.log('Notiflix');
});

Thanks,
Furkan.

@furcan furcan closed this as completed Mar 19, 2022
@furcan furcan added the done Done label Mar 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
done Done enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants