how to make a callbacks work in the liveapi js?
Hi,
Im trying to work out how basic callbacks work in the js liveapi. Im using the following sample code but cant even seem to get a basic callback to work. My understanding is that the way this is supposed to work, is that I give the function an id and it listens to changes on that id and will output a result if a change occurs. However, when i delete the device with the id, it doesnt output anything. Any help understanding this would be much appreciated.
inlets=1;
outlets=2;
function list()
{
var input;
if(inlet==0)
input=arrayfromargs(arguments); // makes an array called "input" from the input list
post("the list contains",arguments.length, "elements"); // how many elements ( ids ) has our input list
post(input[0]); // post the first element (id) just to check its working
var api = new Array();
for (n=0;n
From my experience, you don't get notified for a given callback when something is deleted - you have to listen to the enclosing 'container' which will get called with a list of ids when those ids change (this is how my API works for spotting deletions of tracks/scenes/devices etc)
i.e. if you want to know when a track has been deleted, you need to listen to 'live_set tracks', rather than a specific 'live_set tracks n' - when a track is deleted (or added) you will get called with the current list of ids and you can figure out whether something has appeared or disappeared...
as a side note, are you on my api beta list? All this stuff is now implemented and you get appropriate callbacks :)
btw, if anyone knows different, I'd be glad to know, but for me, a single generic js routine can handle addition/deletion of any type of entity...
also, note that not everything as a property of 'value', e.g. if you want to listen to mute on a track then you listen to the 'mute' property...
Hi Leehu,
Yep, im on your beta list, it looks fantastic. A little advanced for my basic js knowledge, so will take me some time to get into it fully. But nice work :)
Cheers
One thing though, I couldnt see it monitoring chains inside racks, is this a feature of this tool? I could only get it to work on clips
HI, monitoring of chains is there - there is an option on the main gui - 'rack macros only' - make sure this is turned off if you want notifications from inside racks, chains etc - if this is turned on then only the macros for each element will be monitored - i added this mode as it's quite common to not care what is inside a rack, only the exposed macros.... please let me know if this is not working for you....
hopefully, the users of the api will need little js knowledge - just be able to process all the messages that they're interested in - once i get round to writing some docs I'll hopefully explain this more :)