Forums > Jitter

Multiple instances of js object a problem?

March 5, 2007 | 3:02 am

A project I’m working on has four instances of a subpatcher called from a main patcher. The subpatchers use a js object to do a lot of the heavy lifting. I figure I’m probably approaching things wrong since the global code at the beginning of the js object is being invoked multiple times. (Each subpatcher has three instances of the js object with different input messages and outputs at various points in the signal flow. Multiply that times the 4 instances of the subpatcher and that explains why the global code in the common js file is being called 12 times!)

Bottom line: Is this a problem? Do I need to consolidate the three instances of the js object down to one within the subpatcher? And do I need to somehow just invoke the js object once in the master patcher? If so, what approach is recommended for invoking the functions in the js object from various points in the subpatchers?

Thanks so much!

Jeff


March 5, 2007 | 9:10 am

Having multiple js objects is valid usage. Every object has its own scope, apart from the Global objects. Could you post some code?

Mattijs

uote: namaste ranch wrote on Mon, 05 March 2007 04:02
—————————————————-
> A project I’m working on has four instances of a subpatcher called from a main patcher. The subpatchers use a js object to do a lot of the heavy lifting. I figure I’m probably approaching things wrong since the global code at the beginning of the js object is being invoked multiple times. (Each subpatcher has three instances of the js object with different input messages and outputs at various points in the signal flow. Multiply that times the 4 instances of the subpatcher and that explains why the global code in the common js file is being called 12 times!)
>
> Bottom line: Is this a problem? Do I need to consolidate the three instances of the js object down to one within the subpatcher? And do I need to somehow just invoke the js object once in the master patcher? If so, what approach is recommended for invoking the functions in the js object from various points in the subpatchers?
>
> Thanks so much!
>
> Jeff
—————————————————-


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