You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Sep 26, 2025. It is now read-only.
The dispatch() method in OnceSignal, MonoSignal & DeluxeSignal contains duplicated code regarding type checks for payloads:
// If valueClasses is empty, value objects are not type-checked.varnumValueClasses: number=this._valueClasses.length;varnumValueObjects: number=valueObjects.length;// Cannot dispatch fewer objects than declared classes.if(numValueObjects<numValueClasses){thrownewError('Incorrect number of arguments. '+'Expected at least '+numValueClasses+' but received '+numValueObjects+'.');}// Cannot dispatch differently typed objects than declared classes.for(vari: number=0;i<numValueClasses;i++){// Optimized for the optimistic case that values are correct.if(valueObjects[i]===null||valueObjects[i].constructor===this._valueClasses[i])continue;thrownewError('Value object <'+valueObjects[i]+'> is not an instance of <'+this._valueClasses[i]+'>.');}
Code duplication can be removed by delegating this logic to another class i.e. PayloadValidator