enigma.js
enigma.js copied to clipboard
Allow mixins to seamlessly override existing methods
If I add a mixin I have no chance to make something like an "inserOrUpdate".
It would be great to have a section there I can add function and enigma gives me as a parameter if this function exists or not. So that I can decide in my mixin what to do.
For example. We develop an mixin like #272 and a later engine version delivers even on .app an getProperties. With the current enigma.js we have no chance to write a generic working mixin.
Good point!
One way to solve this would be to remove the mixin.extend
and mixin.override
properties and modify the signature of all mixin methods to take baseFn
as its first argument.
For example:
const mixin = {
types: ['Doc'],
init(args) {},
methods: {
method1(baseFn, arg1, arg2) {
if (baseFn) {
// base function exists (overrides existing method)
} else {
// no base function (extends the generated api)
}
}
}
Is this something that would work for you?
Hi @marcusoffesson, this should work, but this mixin.methods is at least at the moment not documented. If this is already in the product please extend https://github.com/qlik-oss/enigma.js/blob/2fe4538cdeeb6d2a174cd78cf96906de91bcfce5/docs/api.md#mixins
Hi @konne! My previous comment should be read as a design proposal and not as something that already exists. Also, we have to consider other things, such as backwards compatibility, etc.
Hi @marcusoffesson, okay, the design proposal sounds great, so this would perfectly work.