On 17 Dec 2015, at 19:58, Tobias Beer <beert...@gmail.com> wrote:
I was wondering if it was possible for my own (widget) code to...
- require some core widget
- overwrite one of the functions of the required module
- use that to create instances for my own widget
Possible?Or do I have to create a custom widget / overwritten one?
Alternatively, is there any chance to hijack any core (widget's) prototype functions?If so, how would one do it?Specifically, I'd like to hijack triggerPopup from the ButtonWidget.Best wishes,Tobias.
--
You received this message because you are subscribed to the Google Groups "TiddlyWikiDev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywikide...@googlegroups.com.
To post to this group, send email to tiddly...@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywikidev.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywikidev/00d7769d-4541-46b3-a90c-adbfb051b1fd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Obviously, this is a technique of last resort…
Popup.prototype.show = function(options) {...}function SuperWidget() {
Widget.apply(this, arguments);
}
SuperWidget.prototype = new Widget();
// Enhance Widget as needed here
function MyWidget() {
SuperWidget.apply(this, arguments);
}
MyWidget.prototype = new SuperWidget();
I think in my head when I read your description I was thinking object inheritance and polymorphism to manage the custom code.
Looking at your code I would push the hackery as far away as possible. Here is a stab at how I would approach the same problem https://gist.github.com/71a1e6b22104ede5f6e7 (Google Groups just had a tantrum attempting to copy/paste the code here. Use the link above. (╯°□°)╯︵ ┻━┻ ).
Also I had thought that the core rendering engine would delay reactions to storage changes till next tick allowing changes to finish and the call stack to exhaust. That way multiple changes to a tiddler only trigger a final DOM render. Does the system not do this? Seems that would be a huge performance issue if it attempted to update the DOM at every step of the call stack.
The only option would be to copy the logic which IMHO is worse then storing twice. Keeping the two in sync would be a nightmare.
Keeping track of and keeping up with core changes would indeed probably be a challenge / source of plenty issues.
There is a third option… Fix the core popup code to have actual useful abstractions so extending the code would not be such a hack in the first place.
I like option three the best.