Why is getvalueof() called multiple times for each call to notifyclients()?

Mar 9, 2012 at 1:46pm

Why is getvalueof() called multiple times for each call to notifyclients()?

I’ve got a js object that holds an array and defines getvalueof() and setvalueof() so I can persist to a pattr.

It works. No problem, but I noticed that when I call notifyclients() my getvalueof() method is called multiple times. I’m not sure why.

inlets = 1;
outlets = 1;

var saved_data = [];

function list(a) {
saved_data.push( a );
notifyclients();
outlet(0, a);
}

function showall() {
for (var i in saved_data) {
post(saved_data[i] + “n”);
}
}

function clear() {
saved_data = [];
notifyclients();
}

function getvalueof() {
post(“Saving.n”);
return saved_data
}

function setvalueof() {
post(“Restoring.n”);
restored_data = arrayfromargs(arguments);
saved_data = restored_data;
post(“Restored.n”);
}

Here’s a simple patch illustrating the behavior:

– Pasted Max Patch, click to expand. –

It’s really bugging me. I can’t tell if this is normal of if I’m missing some poor patching I did somewhere.

When I click on one of the numeric messages to be stored, getvalueof() is called 3 times?!

I must be doing something wrong. Opinions?

#62262
Mar 10, 2012 at 10:25pm

I don’t think you’re doing anything wrong, I think that’s just the way it is. I’d love to know why, though.

#224955
Mar 11, 2012 at 6:19am

Hello,

AFAIK it does more or less the same with C externals ; could be that more than one observer need to know the new value ; storage process, attributes refreshed, UI …

My 2 cents.

#224956
Mar 12, 2012 at 1:17am

Not exactly solving the mystery, but I’m glad I’m not the only one experiencing it. Thanks for the responses!

#224957

You must be logged in to reply to this topic.