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
Add update() method #1186
Add update() method #1186
Conversation
Pull Request Test Coverage Report for Build 4519
💛 - Coveralls |
@zenflow after the green light from, I'll cover the new functionality with tests to keep code coverage on a 90+ level 🥇 |
7146709
to
a0046cb
Compare
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.
@limonte sorry for the delay in getting to this. I've given this review a lot of thought, and I'm generally pretty happy with the change. I'm also really happy about the renderers. I agree it's a great step forward in the organization of the codebase. The next logical step might be to colocate the bits of pre-rendering (construction or setup) logic with their respective renderers.
I linked this against sweetalert2-react-content to test out the API from the point-of-view of an extension. I had to do some reorganization (and fix a prexisting bug sweetalert2/sweetalert2-react-content#58) but it was easy to get the enhancer to work with this feature. You can check out https://github.com/sweetalert2/sweetalert2-react-content/tree/feature/integrate-update-method .. note that the instance properties prefixed __
need to be fixed to be truly private.
Some issues:
The first two are related: Firstly, it would nice if each extension did not need to manage it's own params object; i.e. storing it and updating it. Currently, if you (as an extension) want to know the complete set of effective params
from inside the update
method (not just the subset that are being updated) you need to track that yourself. It's not that much extra code or complexity, but it might not be necessary, i.e. we might be able to handle it in the core. Secondly, the instance's params
property (i.e. the "outer" params, which were defined with the user's call to Swal
) should probably be updated when the update
method is called, as this would likely be expected. As far as I can figure, the only way to do this properly, while still giving subclasses the ability to control the params given to the superclass, would be to have a "protected" method that you can extend that does the actual work, and the update
method just updates the instances public params
property and calls the protected method. This update
method could also solve the first issue by passing the complete set of [outer] params to the protected method.
The other issue is one that is already existing, that I contributed to, that this PR is also contributing to: the exposing of isValidParameter
, isDeprecatedParameter
& isUpdatableParameter
as public methods.. what use case do they serve? and are they expected to be implemented in relevant extensions (that add or remove params)? That's a little bit of overhead, and is likely to be forgotten (even if documented), so I would not necessarily trust them. In most cases, I think it is enough for the public API to log warnings (or throw errors) when you try to do something invalid, so what do you think about deprecating these methods in the public API and removing them in the next major? For now I'm cool with either adding this new isUpdatableParameter
method or not, either way.
9513a65
to
c3c882f
Compare
e5fdbb7
to
3c3fbbb
Compare
d28e146
to
3b53594
Compare
f845ca3
to
b4d009f
Compare
oops, wrong button |
b4d009f
to
2b93491
Compare
2b93491
to
1bc570d
Compare
I'll just ship this feature as it is |
@limonte Disappointed that we could not work on this so that it remains easy to extend Swal.. Also, in my comment I indicated a problem/bug:
|
Happy to work on that @limonte @zenflow if you think it's worth it. My only question (to better understand how it can be used) is what would be the use case for that @zenflow? Let's say that a developer change the swal |
# [8.0.0](v7.33.1...v8.0.0) (2019-01-19) * BREAKING CHANGE: remove getButtonsWrapper() ([c93b5e3](c93b5e3)) * BREAKING CHANGE: close() as instance method (#1379) ([2519c17](2519c17)), closes [#1379](#1379) * BREAKING CHANGE: replace deprecated `jsnext:main` with `module` in package.json (#1378) ([1785905](1785905)), closes [#1378](#1378) * BREAKING CHANGE: drop Bower support (#1377) ([cb4ef28](cb4ef28)), closes [#1377](#1377) * BREAKING CHANGE: remove withNoNewKeyword enhancer (#1372) ([f581352](f581352)), closes [#1372](#1372) * BREAKING CHANGE: remove swal.noop() ([40d6fbb](40d6fbb)) * BREAKING CHANGE: rename $swal2-validationerror -> $swal2-validation-message (#1370) ([9d1b13b](9d1b13b)), closes [#1370](#1370) * BREAKING CHANGE: inputValidator and preConfirm should always resolve (#1383) ([fc70cf9](fc70cf9)), closes [#1383](#1383) * BREAKING CHANGE: remove setDefault and resetDefaults (#1365) ([97c1d7c](97c1d7c)), closes [#1365](#1365) * BREAKING CHANGE: remove extraParams (#1363) ([5125491](5125491)), closes [#1363](#1363) * BREAKING CHANGE: remove showValidationError and resetValidationError (#1367) ([50a1eff](50a1eff)), closes [#1367](#1367) * BREAKING CHANGE: remove useRejections and expectRejections (#1362) ([f050caf](f050caf)), closes [#1362](#1362) * BREAKING CHANGE: dismissReason: overlay -> backdrop (#1360) ([d05bf33](d05bf33)), closes [#1360](#1360) * BREAKING CHANGE: drop Android 4.4 support (#1359) ([c0eddf3](c0eddf3)), closes [#1359](#1359) ### Features * **api:** add update() method ([#1186](#1186)) ([348e8b7](348e8b7)) ### BREAKING CHANGES * close() as instance method (#1379) * drop Android 4.4 support (#1359) * replace deprecated `jsnext:main` with `module` in package.json (#1378) * drop Bower support (#1377) * remove withNoNewKeyword enhancer (#1372) * remove swal.noop() * rename $swal2-validationerror -> $swal2-validation-message (#1370) * inputValidator and preConfirm should always resolve (#1383) * remove setDefault and resetDefaults (#1365) * remove extraParams (#1363) * remove showValidationError and resetValidationError (#1367) * remove useRejections and expectRejections (#1362) * dismissReason: overlay -> backdrop (#1360) * remove getButtonsWrapper()
@zenflow I personally do not see any of those as critical issues, if they are we will fix them and ship as patch releases because they will not affect public APIs. Please elaborate a bit more on:
Proper issue-reports (with some code, actual and expected behaviors) and/or PRs are very welcome. |
Opened #1386 ... The other recommendations were critical to Swal being easy to extend.. something I worked very hard on. Those recommendations included changes to the "protected" API (i.e. extensions depend on it; changes to it can break code outside of this repo) as well as the public API (e.g. removing isValidParameter, isDeprecatedParameter & isUpdatableParameter from the public API). I'm not sure why you are so hasty to make the major release, when there are still many things in the API that could have been fixed or improved, e.g. #1373, but now we are stuck with for another major version, unless you are fine with making major breaking changes in patch releases. |
The process of releasing a new major took 11 days: aa657e5...v8.0.0 I wouldn't call it hasty. Everybody noticed PRs with "BREAKING CHANGE" in their titles and was able to participate. We all have limited time, I personally don't need anything from #1373 or #1386 for my projects, that is why I didn't work on them. At the same time, new major contains some really important changes (e.g. ES modules support) which people need and my responsibility as a mantainer fo this project is to ship that as soon as possible. #1373 has appeared after I started the new major process and it lacks use-cases with code examples, actual and expected behaviors, that's why I didn't work on it. I will ask for clarifications there, but it's a bit impolite to drop issues without following issue templates and expect them to be done. |
I believe this is much better than #1152
Renderers were introduced recently, there are currently 2 renderers: https://github.com/sweetalert2/sweetalert2/tree/master/src/utils/dom/renderers
Renderers allow to re-render particular parts of a popup without re-initialization:
I'm quite happy with this implementation. What do you think @zenflow?