This is useful because SHOW emits an id, and so should CLOSE -- that way it's possible to know all open and closed popups. e.g.,
constructor(props) {
super(props);
this.state = {
openPopups: [],
};
Popup.addShowListener((pid) => {
if (!this.state.openPopups.includes(pid)) { // this is because SHOW is also emitted when a popup is opened from the queue.
this.setState(({ openPopups }) => ({
openPopups: [...openPopups, pid],
}));
}
});
Popup.addCloseListener((pid) => {
this.setState(({ openPopups }) => ({
openPopups: openPopups.filter(id => id !== pid),
}));
});
}
Ah thanks for this, close should obviously emit and ID as well. I'll merge it in right away. I'm making it a part of the v1.0.0 milestone. So it will go out together with some other stuff on February 15th.
This is useful because
SHOW
emits anid
, and so shouldCLOSE
-- that way it's possible to know all open and closed popups. e.g.,