Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #37211 > unrolled thread
| Started by | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| First post | 2019-09-10 23:39 -0700 |
| Last post | 2019-09-12 00:10 -0700 |
| Articles | 7 — 1 participant |
Back to article view | Back to comp.lang.javascript
Howto rlelease the onmidimessage listener? Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-09-10 23:39 -0700
Re: Howto rlelease the onmidimessage listener? Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-09-10 23:51 -0700
Re: Howto rlelease the onmidimessage listener? Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-09-11 02:04 -0700
Re: Howto rlelease the onmidimessage listener? Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-09-11 02:34 -0700
Re: Howto rlelease the onmidimessage listener? Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-09-11 02:38 -0700
Re: Howto rlelease the onmidimessage listener? Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-09-11 13:16 -0700
Re: Howto rlelease the onmidimessage listener? Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-09-12 00:10 -0700
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2019-09-10 23:39 -0700 |
| Subject | Howto rlelease the onmidimessage listener? |
| Message-ID | <2ee6f8a1-220e-4618-899d-e82a30e2e3b4@googlegroups.com> |
This is the most common way people show howto implement inport listeners, they just scroll thru all.
for (input = inputs.next(); input && !input.done; input = inputs.next()) {
input.value.onmidimessage = onMIDIMessage;
}
I have searched for howto release the listener but can not find information about it. Do anyone here know?
So instead i had the idea to reinitiate the whole requestMIDIAccess, that i thought would release the whole midiObject unfortunately is just created a new instance running on top.
So can anyone show me to information "preferably web example" on howto either.
release onMIDIMessage listener
OR
release requestMIDIAccess object/promise "whatever it is"
[toc] | [next] | [standalone]
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2019-09-10 23:51 -0700 |
| Message-ID | <47590108-5af2-432b-aa93-1bed60be8656@googlegroups.com> |
| In reply to | #37211 |
Den onsdag 11 september 2019 kl. 08:39:21 UTC+2 skrev Jonas Thörnvall:
> This is the most common way people show howto implement inport listeners, they just scroll thru all.
>
> for (input = inputs.next(); input && !input.done; input = inputs.next()) {
> input.value.onmidimessage = onMIDIMessage;
> }
>
> I have searched for howto release the listener but can not find information about it. Do anyone here know?
>
> So instead i had the idea to reinitiate the whole requestMIDIAccess, that i thought would release the whole midiObject unfortunately is just created a new instance running on top.
>
> So can anyone show me to information "preferably web example" on howto either.
>
> release onMIDIMessage listener
>
> OR
>
> release requestMIDIAccess object/promise "whatever it is"
Here you can check out how it layers the instances as you check/uncheck the inport boxes.
https://midisequenser.000webhostapp.com/
[toc] | [prev] | [next] | [standalone]
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2019-09-11 02:04 -0700 |
| Message-ID | <6a83bab3-aa20-4a71-b0d1-1f11ac8376d9@googlegroups.com> |
| In reply to | #37212 |
Den onsdag 11 september 2019 kl. 08:51:15 UTC+2 skrev Jonas Thörnvall:
> Den onsdag 11 september 2019 kl. 08:39:21 UTC+2 skrev Jonas Thörnvall:
> > This is the most common way people show howto implement inport listeners, they just scroll thru all.
> >
> > for (input = inputs.next(); input && !input.done; input = inputs.next()) {
> > input.value.onmidimessage = onMIDIMessage;
> > }
> >
> > I have searched for howto release the listener but can not find information about it. Do anyone here know?
> >
> > So instead i had the idea to reinitiate the whole requestMIDIAccess, that i thought would release the whole midiObject unfortunately is just created a new instance running on top.
> >
> > So can anyone show me to information "preferably web example" on howto either.
> >
> > release onMIDIMessage listener
> >
> > OR
> >
> > release requestMIDIAccess object/promise "whatever it is"
>
> Here you can check out how it layers the instances as you check/uncheck the inport boxes.
>
> https://midisequenser.000webhostapp.com/
The ugly solution is to not have any listener attached at load, wait until user checkboxes and confirm what ports to listen.
But i think that is a copeout of course port listener should be active at load.
It would be strange if it is not possible to remove and load the listener at an inport.
[toc] | [prev] | [next] | [standalone]
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2019-09-11 02:34 -0700 |
| Message-ID | <272b5ef2-e206-4e7f-a4d2-cf9fde245409@googlegroups.com> |
| In reply to | #37211 |
Den onsdag 11 september 2019 kl. 08:39:21 UTC+2 skrev Jonas Thörnvall:
> This is the most common way people show howto implement inport listeners, they just scroll thru all.
>
> for (input = inputs.next(); input && !input.done; input = inputs.next()) {
> input.value.onmidimessage = onMIDIMessage;
> }
>
> I have searched for howto release the listener but can not find information about it. Do anyone here know?
>
> So instead i had the idea to reinitiate the whole requestMIDIAccess, that i thought would release the whole midiObject unfortunately is just created a new instance running on top.
>
> So can anyone show me to information "preferably web example" on howto either.
>
> release onMIDIMessage listener
>
> OR
>
> release requestMIDIAccess object/promise "whatever it is"
Can i ask why do not the webmidiAPI use add remove eventlistener?
Would it not been more logical with.
input.addEventListener("onMidiMessage");
input.removeEventListener("onMidiMessage");
and if inputs was an array instead of an iterator.
inputs[].addEventListener("onMidiMessage");
inputs[].removeEventListener("onMidiMessage");
Sometimes the solutions the guys who implement javascript just do not make sense to me. I guess they have their reasons for implementing it the way they does, but it is totally beyond my understanding of the language.
How come i can search for hours but not come up with howto remove a listener for a port, isn't that fucking strange?
Either it is so cumberly hard to do that noone put the effort into do it. Or it is impossible. If someone put in the effort to do it, please post me the link.
[toc] | [prev] | [next] | [standalone]
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2019-09-11 02:38 -0700 |
| Message-ID | <ac526804-44dd-48c2-8b63-40c144daf028@googlegroups.com> |
| In reply to | #37211 |
Den onsdag 11 september 2019 kl. 08:39:21 UTC+2 skrev Jonas Thörnvall:
> This is the most common way people show howto implement inport listeners, they just scroll thru all.
>
> for (input = inputs.next(); input && !input.done; input = inputs.next()) {
> input.value.onmidimessage = onMIDIMessage;
> }
>
> I have searched for howto release the listener but can not find information about it. Do anyone here know?
>
> So instead i had the idea to reinitiate the whole requestMIDIAccess, that i thought would release the whole midiObject unfortunately is just created a new instance running on top.
>
> So can anyone show me to information "preferably web example" on howto either.
>
> release onMIDIMessage listener
>
> OR
>
> release requestMIDIAccess object/promise "whatever it is"
And is it not strange that there is no simple way to release the midAccess promise object.
Something like drop.midiAccess
[toc] | [prev] | [next] | [standalone]
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2019-09-11 13:16 -0700 |
| Message-ID | <e666a2c3-48ef-48ea-b3b3-a8331c04e257@googlegroups.com> |
| In reply to | #37211 |
Den onsdag 11 september 2019 kl. 08:39:21 UTC+2 skrev Jonas Thörnvall:
> This is the most common way people show howto implement inport listeners, they just scroll thru all.
>
> for (input = inputs.next(); input && !input.done; input = inputs.next()) {
> input.value.onmidimessage = onMIDIMessage;
> }
>
> I have searched for howto release the listener but can not find information about it. Do anyone here know?
>
> So instead i had the idea to reinitiate the whole requestMIDIAccess, that i thought would release the whole midiObject unfortunately is just created a new instance running on top.
>
> So can anyone show me to information "preferably web example" on howto either.
>
> release onMIDIMessage listener
>
> OR
>
> release requestMIDIAccess object/promise "whatever it is"
Well i tried at midi association forum so far noone replied, if that mean it is not possible they do not know or it is just complicated i do not know.
So i fear the ugly solution with the inport checkboxes generated in a separate frame is at hand unless someone got an better idea. Because that way i can reload main and keep the checkboxes settings alive at least i hope so.
So any better suggestions?
[toc] | [prev] | [next] | [standalone]
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2019-09-12 00:10 -0700 |
| Message-ID | <82041d47-9cb5-4c7a-8d61-25c7f8b64f47@googlegroups.com> |
| In reply to | #37233 |
Den onsdag 11 september 2019 kl. 22:16:28 UTC+2 skrev Jonas Thörnvall:
> Den onsdag 11 september 2019 kl. 08:39:21 UTC+2 skrev Jonas Thörnvall:
> > This is the most common way people show howto implement inport listeners, they just scroll thru all.
> >
> > for (input = inputs.next(); input && !input.done; input = inputs.next()) {
> > input.value.onmidimessage = onMIDIMessage;
> > }
> >
> > I have searched for howto release the listener but can not find information about it. Do anyone here know?
> >
> > So instead i had the idea to reinitiate the whole requestMIDIAccess, that i thought would release the whole midiObject unfortunately is just created a new instance running on top.
> >
> > So can anyone show me to information "preferably web example" on howto either.
> >
> > release onMIDIMessage listener
> >
> > OR
> >
> > release requestMIDIAccess object/promise "whatever it is"
>
> Well i tried at midi association forum so far noone replied, if that mean it is not possible they do not know or it is just complicated i do not know.
>
> So i fear the ugly solution with the inport checkboxes generated in a separate frame is at hand unless someone got an better idea. Because that way i can reload main and keep the checkboxes settings alive at least i hope so.
>
> So any better suggestions?
Solved!
Evidently I sometimes think javascript syntax is more complex then it is.
input.value.onmidimessage = null;
function checkInPorts(){
var x=0;
inputs = mid.inputs.values();
for (var input = inputs.next(); input && !input.done; input = inputs.next()) {
input.value.onmidimessage = null;
var myVar = document.getElementById("inBox" + x).checked;
if(myVar==false){ }
else if(myVar==true){ input.value.onmidimessage = onMIDIMessage;}
x++;
}
}
https://midisequenser.000webhostapp.com
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.javascript
csiph-web