Skip to content

No context possible for events? #1492

@LlGC-jop

Description

@LlGC-jop

UV version:

I'm submitting a:

  • bug report => please fork one of these codesandbox examples with a repro of your issue and include a link to it below
  • feature request => please use the user stories repo
  • support request => Please do not submit support requests here, use stackoverflow

Current behavior:

In documenting the events system in the viewer I've found that the UV.on() function (and the similar function in BaseContentHandler) allows for a 3rd argument, ctx, to provide a 'this' context for the callback function.

However, as far as I can tell this argument is never* used because in BaseContentHandler this code this.on(name, cb); doesn't pass ctx so when this runs evtArr[i].cb.apply(evtArr[i].ctx, data); ctx is always undefined.

*The only places it sort-of is used are internally (Init and URLAdapter) and it's always passed as false.

Expected behavior:

I'm not sure what the planned behaviour was, or if it's like this just to make sure 'this' is undefined, but we could possibly change it to be evtArr[i].cb(...data); and remove the ctx argument so it's not confusing matters.

Solution?

If possible I'd like someone to sense check to make sure I'm not missing anything, and then we can discuss whether to make the ctx argument do something, or remove it. I'm leaning towards the latter, as I think adding it might be a sort-of breaking change.

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions