First, create a Data Element of Type `JS Object`. For Path, specify the JS variable you want to "watch" for. Note that it must be a variable within the global (`window`) scope.
Next, Create an Event Based Rule. In the Conditions > Event section, select Event Type `dataelementchanged`, and select your Data Element from the dropdown.
At this point, the rule will now trigger whenever the value of your JS variable changes. If you want it to only trigger on certain values, then under Rule Conditions > Criteria, Select `Data : Data Element Value`, and click Add Criteria. Then select your data element from the Data Element dropdown, and specify your expected value in the Value field.
General note: `dataelementchanged` works by using `window.setTimeout` to poll the data element every ~100ms to compare the current value with the previous value. So there is site performance to consider with this type of event, especially if you plan on using it for many rules.