unsubscribe: function()

in salesforce/canvas/public/javascripts/canvas-all.js [1123:1157]


          unsubscribe: function (client, s) {
            var subs = {};
            if ($$.isNil(s) || !validateClient(client)) {
              throw 'PRECONDITION FAIL: need fo supply client and event name';
            }
            if ($$.isString(s)) {
              subs[s] = {};
              delete subscriptions[s];
            } else {
              $$.each($$.isArray(s) ? s : [s], function (v) {
                var name = v.name ? v.name : v;
                validName(name, ['canvas', 'sfdc']);
                subs[name] = { params: v.params };
                if (name === STR_EVT) {
                  if (!$$.isNil(subscriptions[name])) {
                    if (!$$.isNil(subscriptions[name][v.params.topic])) {
                      delete subscriptions[name][v.params.topic];
                    }
                    if ($$.size(subscriptions[name]) <= 0) {
                      delete subscriptions[name];
                    }
                  }
                } else {
                  delete subscriptions[name];
                }
              });
            }
            if (!client.isVF) {
              postit(null, {
                type: 'unsubscribe',
                config: { client: client },
                subscriptions: subs,
              });
            }
          },