pex-renderer icon indicating copy to clipboard operation
pex-renderer copied to clipboard

Add source to change events

Open vorg opened this issue 7 years ago • 1 comments

Currently it's impossible to know who emitted the change in the callback

function onParamChange (name) {
  console.log('param ${name} has changed')
}

// start listening
entity.transform.changed.add(onParamChange)

// done internaly by transform whenever position changes
entity.transform.dispatch('position')

// stop listening
entity.transform.changed.remove(onParamChange)

vorg avatar Aug 13 '18 08:08 vorg

What about using the listenerContext param: add(listener, listenerContext, priority)

function onParamChange (name) {
  console.log('param ${name} has changed')
  console.log('From entity', this)
}

entity.transform.changed.add(onParamChange, entity)

dmnsgn avatar Jan 21 '19 14:01 dmnsgn