Forums > Javascript

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

Mar 09 2012 | 1:46 pm

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 );
outlet(0, a);

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

function clear() {
saved_data = [];

function getvalueof() {
return saved_data

function setvalueof() {
restored_data = arrayfromargs(arguments);
saved_data = restored_data;

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?

Mar 10 2012 | 10:25 pm

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.

Mar 12 2012 | 1:17 am

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

Viewing 3 posts - 1 through 3 (of 3 total)

Forums > Javascript