How to listen to 'select' events?

I’m a little confused over the select event

WL.registerComponent('click', {
}, {

  update: function() {
    WL.xrSession.addEventListener('select',my_callback_function());
   
  }
});

function my_callback_function(){
  console.log("this method works ");
}

<@!264452965862080512> Is this the right Js syntax to detect click event ?

In the version u have now the issue is that u are adding it in update
And u call it
So it will log
You should do this kind of things just once
But in the version without the () it should not call like that

Thanks, the bug is fixed when I removed (), its now only calling when I click!!
Dont know why But when I move it to init the function is not even calling, seems to work for me in update
(using chrome mobile browser with cardboard)

init does not give any guarantee on other components being initialized already
in start you can expect init() to have been called on any component you might get through getComponent()
So working with other components should always be done in start, but initializing default values/members should go in init()

Here you additionally have the problem, that WL.xrSession might be null until the user clicked on the VR button, here’s a snippet:


init: function() { /* or start, doesn't make a difference here */
    if(WL.xrSession) {
        WL.xrSession.addEventListener(...);
    } else {
        WL.onXRSessionStart.push(s => s.addEventListener(...) );
    }
},