Closed cristianvogel closed 1 year ago
To make sure I understand this correctly, let me ask: because each WebRenderer instance is its own EventEmitter, don't you get events scoped to the correct instance by default?
let core1 = new WebRenderer();
let core2 = new WebRenderer();
// Initialization and stuff omitted for brevity
core1.on(<anything>, (e) => {
// You know this is coming from core1
});
core2.on(<anything>, (e) => {
// You know this is coming from core2
});
For me that seems to provide everything we would need to distinguish which events come from which instance.
Is this an acceptable way of adding such a custom property?
Object.defineProperty(renderer, 'id', { value: id, writable: false });
Sure, if you like! JavaScript lets you do all kinds of stuff; you could just renderer.id = id;
too.
Yeah, I'm loving it. Its my favourite language after SmallTalk ;)
Right on :). Good to close this issue then?
I am developing a larger web site with Elementary basically in replacement of the global Audio object and WebAudio generic.
In this context, I am finding it useful to instantiate multiple WebAudioRenderer ( alias WebRenderer ? )
What would be useful to make sure everything is routed and targeted correctly, is some introspection.
I am proposing an optional
id
field in the constructor, that at least gets returned at theload()
event but also maybe from a getter once loaded.https://github.com/elemaudio/elementary/blob/05d8acd2b2c49228d1f8717da67015d5ceffeec2/js/packages/web-renderer/raw/WorkletProcessor.js#LL85C1-L91C4