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

Sort out instance and static methods #1373

Open
zenflow opened this issue Jan 9, 2019 · 1 comment
Open

Sort out instance and static methods #1373

zenflow opened this issue Jan 9, 2019 · 1 comment

Comments

@zenflow
Copy link
Member

zenflow commented Jan 9, 2019

Right now, for backwards compatibility, all instance methods are also exposed as static methods, via proxy methods defined here:

// Proxy to instance methods to constructor, for now, for backwards compatibility
Object.keys(instanceMethods).forEach(key => {
SweetAlert[key] = function (...args) {
if (currentInstance) {
return currentInstance[key](...args)
}
}
})

We should

  • drop this block of code
  • change the appropriate static methods to instance methods (e.g. Swal.getTitle() -> swal.getTitle()). Should make sure that calling these methods apply to that particular instance, and not the currently active swal, since they can be different. (Note: there are no instance methods that should become static methods)
  • add static method like Swal.getCurrentInstance(), which will be generally useful, and also allow for easy migration in situations where a user is using one of the methods that were changed to an instance method, but they didn't save a reference to the instance
  • Split documentation on methods into static methods and instance methods
@zenflow zenflow changed the title Sort out instance and static methods for upcoming major Sort out instance and static methods some day Jan 19, 2019
@limonte limonte changed the title Sort out instance and static methods some day Sort out instance and static methods Jan 19, 2019
@limonte
Copy link
Member

limonte commented Jan 19, 2019

This looks like a feature request. In future please follow the templates when you reporting/requesting something to be done.

This request is missing the "New feature motivation" section. Please describe the context, the use-case and the advantages of the feature request. What will change for end-users and why do they need this feature?

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