JS autowatch issue when used with JS require.
Oct 15 2020 | 10:50 pm
Hi, I use to use the 'autowatch = 1' feature in my JS files in order to recompile them automatically after an edit. Since I use the JS require mechanism to split my JS code in several parts, it seems that the autowatch mechanism gets a bit buggy and I can't figure why... Can you help me ? The context I'm currently designing a MIDI editor for a hardware synth with Max for Live. My design is based on an MVC pattern. My model and my controller are pure JS patchers. The controller includes a viewManager.js file (with JS require) to communicate with the view, which is a standard Max patcher. The view contains classical UI objects, the JS code uses a ParameterListener object in order to control the UI objects (set/get). So no patch chords are required to make the controller and the view communicate with each other.
The problem At dev time, when I edit my code in the viewManager.js and save it, it seems to be not recompiled automatically with autowatch. Indeed, when I change the dial's value in the view, the Max console outputs strange 'ghost' values that look like the previous ones I've used in my code ! And if I edit my code many times, it seems that the Max console outputs the 'history' of all my edits, that is really disturbing... Please help ! I've built a simple example project with Max 8.1.7 in order to demonstrate the issue I encounter with the JS autowatch property, when used with JS require. I would appreciate if someone could : • download and unzip my Max example project (Max 8.1.7 required because of the new ParameterListener 'silent' mechanism) • open the 'jsAutowatchIssue.amxd' project in Max (I'm an Ableton Live user) • open the 'view' patcher (in blue) • open the controller.js and the viewManager.js files in an external text editor (I use TextMate) • have a look at the 'onDialChanged' function in viewManager.js • do the first and second tests step by step, as described in my comments • let me know what are the outputs in the Max console
Thank you for your help :) Regards, Guillaume