One of the advantages of RequireJS and Steal is not polluting the global scope, so while your solution does work, you are just using global variables.
When Control processes an name in the curly braces, it first looks in the Control's options and then the window. So you can do this:
- define(['can', 'core/global/appState'], function(can, AppState) {
- return can.Controll({
- defaults: {
- appState: AppState
- }
- }, {
- init: function(element, options){
- },
- '{appState} change': function(ev, attr, how, newVal, oldVal) {
- console.log('appState changed2', ev, attr, how, newVal, oldVal);
- },
- });
- });