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
I didn't understand this requirement; "if obj.trigger is called with additional arguments it should pass those to the listeners". Could you please provide an example of what is expected?
The text was updated successfully, but these errors were encountered:
Hi @FarisMarouane. Great question! The crux of what that part of the challenge is asking for is that if an event type is called with trigger, any extra arguments after the event name should be passed as arguments to the event listener that is invoked.
Here's an example adapted from that challenge's test file.
constobj=addEventing({foo: 'bar'})consteventHandler=(arg1,arg2)=>{console.log('FIRST ARG:',arg1)console.log('SECOND ARG:',arg2)}obj.on('event',eventHandler)// invoke `event` and pass it `arg1` and `arg2` as argumentsobj.trigger('event','Hello world',42)// logs "FIRST ARG: 'Hello world'" and "SECOND ARG: 42"
However, we want to write our trigger() method to take any number of arguments, each of which should be forwarded on as arguments to the listeners when an event is triggered.
Does that explanation help? Please feel free to ask for more clarification, I'd be happy to provide it :)
I didn't understand this requirement; "if obj.trigger is called with additional arguments it should pass those to the listeners". Could you please provide an example of what is expected?
The text was updated successfully, but these errors were encountered: