Welcome to the Linux Foundation Forum!

LFW211 JSNAD CH-9 LABS-1

So, I have the solution of

ee.once('tick', listener)

But can anyone explain why the following options do not work?

ee.once('tick', listener())

OR

ee.once('tick', 
  () => {
    listener()
  }
)

Seems like most of the time I waste is dancing around silly syntax errors like this and I wish I understood when I'm permitted to pass an empty constructor to a function.

Comments

  • xdxmxc
    xdxmxc Posts: 157

    @samuelbernardy yes knowledge of syntax certainly helps, but it gets more familiar and therefore easier over time

    the format is:
    ee.once(name, listenerFunction)

    So your first one works because you're passing a function, the second one doesn't work because you're passing whatever listener returns (you're calling the function) which I expect in this case is undefined and so you'd see an error like "undefined is not a function"

    And the last case, must be a false negative for you because that will also work, you're passing a function which is called once tick event is emitted, and that function in turns calls the listener function.

Categories

Upcoming Training