-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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(modal): get all the open modal instances using the NgbModal (#3627) #3650
Conversation
e659de2
to
f439a61
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.
I am not sure I understand why we would need a forEach
public API for that purpose...
I see 2 options in here:
- Can't we create a dynamic getter returning the open modals ? then users decide what they wan't to do.
or
- Can't we create an observable, we emit each time a modal is opened/closed. Users subscribe and do what they want with it. (I would be in favour of that one)
@maxokorokov @fbasso WDYT ?
Agree with @benouat concerns - can we discuss more the the public API we want to expose? |
On my side, I agree with Benoit regarding the forEach API : it forces the developer to use a loop, so it's not flexible enough (what if we just want the number of opened modals, for example ?). Regarding the solution, I would be be in favor of the first one, for practical reason (and considering the use case explained in #3627. With a subscribe, I guess that there would be a need to subscribe on each modal (to get the modal instance in the subscribe ?), and my feeling is it' can be painful. On the other hand, the subscribe will allow to select modals where specific actions are required, letting the others apart. So I have no clear idea of what to do here :) |
No, I was more thinking about the equivalent of a |
This seems a little counter-intuitive. The first time I read I though the observable would emit the ref any time a new child modal was opened. Between the two options, I prefer the first and let the user iterate over the instances. |
It might, arguably, feel counter-intuitive, but it's exactly how QueryList are working when using |
I would like that we move on with this one. @pkozlowski-opensource Could we use directly
https://github.com/angular/angular/blob/master/packages/core/src/linker/query_list.ts |
f439a61
to
0d41b51
Compare
Codecov Report
@@ Coverage Diff @@
## master #3650 +/- ##
==========================================
+ Coverage 91.23% 91.31% +0.08%
==========================================
Files 100 100
Lines 2988 2993 +5
Branches 555 555
==========================================
+ Hits 2726 2733 +7
+ Misses 192 191 -1
+ Partials 70 69 -1
Continue to review full report at Codecov.
|
@benouat hmmm, not sure which part of QueryList is a perfect fit here? Are you talking about notifications? I guess I need more context as for now I'm not sure how we could take advantage of |
@pkozlowski-opensource We need to maintain a "live" list of items in a way that would be a Iterable, with helpers sur as Looking at it, my description is 100% matching what the class QueryList is providing. am I wrong ? Regarding our feature, we would then maintain a |
@benouat I see. I would rather stay away from using The main problem is that All in all I think it is safer to craft a minimal interface + impl and avoid dependency on sth that is likelly to change in the future. |
That's exactly for this kind of information that I pinged you! Thanks 🙏 |
UPDATE: NgbModal has a new property: activeInstances @benouat Please review. |
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.
LGTM! Thanks
Before submitting a pull request, please make sure you have at least performed the following: