onPointerUp and friends vs. onPointerObservable : current recommendations?

I hope I didn’t read the official documentation too quick…

I ran today into a quite old forum comment from @RaananW here where Raanan wrote that onPointerUp is technically deprecated.

To this day, I still use this syntax over Observables sometimes, typically when it results in cleaner code.

Should I strive for systematically using the Observables pattern nowadays?
And while I’m at it: is there any performance difference between the two approaches? (I’m thinking in particular when events are fired at high frequency e.g. pointer movement events.)

Thanks!

We never really deprecated it, but we did provide a better API. As we guaranty backwards-compatibility, those APIs will stay there for as long as you use the current packages we provide.

We recommend using the observables, as we believe this is the better architecture for your application. One of the reasons is that by setting onPointerUp you are changing the babylon context (adding a function to the BABYLON namespace), whereas when you use observables you attach yourself to an already-existing observable.

But, eventually - use whatever you feel fits your application. Those function definitions will not be removed from the scene :slight_smile:

2 Likes

What’s the status of onPointerDown (observable), are all browser now returning it? Thx,

Are there any issues with onPointerDown?

Back in 2018-9, there was. I remember having an exchange with @Deltakosh back then. So, I left it out but I have to admit I never tried again since. That’s why I’m asking. Obviously, I understand from your answer that everything should be fine now? :smiley:

We wouldn’t have survived that long without an onPointerDown support :slight_smile:

All should work as expected. And if you know what the issues was and can check it would be great

Apple can survive a decade without fixing major issues :wink: :face_with_open_eyes_and_hand_over_mouth:

2 Likes

Great, thanks for the update! :slight_smile:

I was trying to find this (very) old post but it must have been part of something else. If I (automagically :wink: find it again, I’ll let you know.

Luckily I prefer other fruits :slight_smile: