>>4428>Passing constant values as arguments wouldn't improve anything.Of course it would. Right now you have: capture args and create no-arg function, capture this no-arg function, call this no-arg function. The result is that every invocation of createWojakifyButton in every *-common.ts file is given a freshly constructed no-arg arrow function for that button. By contrast, if you switch to
>>4426 you would have: capture function and args, call function with those args. This way every invocation of createWojakifyButton for a platform could receive exactly the same callback function, only the args to be used by button.onclick would differ.
>The way I did it on other platforms is basically instead of creating callbacks for each button for each post, I create a wrapper of createWojakifyButton that passes an arrow function as the callback that captures the id.But the "instead of creating callbacks for each button for each post" is exactly what is verifiably false. Right now you are creating a new callback for each button in each invocation of createWojakifyButton in *-common.ts. This is what
>>4426 would eliminate.
From vichan-common.ts:
protected createImageWojakifyButton(id: string, nth: number) {
return createWojakifyButton('wojakify-image', 'Wojakify Image', () => {
generateImageWojak(this.accessor.getPostImageURL(id, nth), options[this.sojakSelector.value]).then(wojak => this.handleWojakify(wojak, id));
});
}
That creates a fresh callback for each button.