Conversation
…nsuring show() has full access
| const show = (targetModal, config) => { | ||
| const options = config || {} | ||
| options.targetModal = targetModal | ||
| const showOptions = config || options |
There was a problem hiding this comment.
@mjs1994 , if I get it right the idea was to keep config settings from the init function and update them when we pass new config settings into a show function.
In your implemetation you ignore the init config if new config settings have been passed to the show function.
There was a problem hiding this comment.
Yes, the idea was to call init with some global settings, then when you call show it can read from these global settings rather than you having to pass them in again.
Yes it will ignore the global settings if you pass in a new config for this show method. It may also be a good idea to combine the two (incoming config & global config), but for simplicity I'd rather just read from the global ones or have explicit control by passing in a new config entirely if required for the show.
There was a problem hiding this comment.
@mjs1994 , thank you for your reply. Yep, I agree that for simplicity sake we may keep your approach to show settings. But from my point of view it's rather odd, it just does not feel right, that we can create a new modal object with different settings by passing a single custom config param to the show function. I don't expect such a behaviour, because for me, when I call a show function I'm referring to the modal that I have already initialized earlier.
Store the options at a module level so we can initialise once:
And share them with
.show()so we can still use this simple method:MicroModal.show('RequestAQuote');