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 request: callback #3

Open
catskull opened this issue Nov 11, 2019 · 2 comments
Open

Feature request: callback #3

catskull opened this issue Nov 11, 2019 · 2 comments

Comments

@catskull
Copy link
Contributor

It would be nice if the various show methods returned a promise so you could automatically do something when the snackbar times out.

Thinking it would work something like this:

this.$snackbard.show({
  text: 'Click here for more info.',
  buttonText: 'INFO',
  onClick: this.showMoreInfo()
}).then(() => {
  this.showMoreInfo()
}

Alternatively it could be a part of the payload like this

this.$snackbard.show({
  text: 'Click here for more info.',
  buttonText: 'INFO',
  onClick: this.showMoreInfo(),
  onTimeout: this.showMoreInfo()
})
@Mando75
Copy link
Contributor

Mando75 commented Nov 11, 2019

I wouldn't mind implementing this. I think the I think it would be best to just chain the promise. What kind of payload (if any) do you think the Promise should resolve with?

@catskull
Copy link
Contributor Author

Maybe the promise could be resolved with something like this:

{
  wasTimedOut: true,
  wasClicked: false
}

And then you could just chain the promise instead of passing onClick into the payload?

Though since the API is already set up for functions to be passed into the payload, maybe we should go with that approach.

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

No branches or pull requests

2 participants