Add a new callback.
494467
def add_callback(self, events, callback):
        """"""
        if self._poll is None:
            raise RuntimeError('poll instance is closed')
        if events & ~(READABLE|WRITABLE):
            raise ValueError('illegal event mask: {}'.format(events))
        if events & READABLE:
            self._readers += 1
        if events & WRITABLE:
            self._writers += 1
        handle = add_callback(self, callback, events)
        self._sync()
        return handle
283629
private function _addCallback($cls, $callback, $func) 
    {
        self::_initiateCallbacks($cls);
        array_push(self::$_callbacks[$cls][$callback], $func);
    }
1192025
def add_update_callback(self, group=None, name=None, cb=None):
        
        if not group and not name:
            self.all_update_callback.add_callback(cb)
        elif not name:
            if group not in self.group_update_callbacks:
                self.group_update_callbacks[group] = Caller()
            self.group_update_callbacks[group].add_callback(cb)
        else:
            paramname = '{}.{}'.format(group, name)
            if paramname not in self.param_update_callbacks:
                self.param_update_callbacks[paramname] = Caller()
            self.param_update_callbacks[paramname].add_callback(cb)
108082
def register_callback(self):
        """"""

        cid = str(self.__cid)
        self.__cid += 1
        event = queue.Queue()
        self.__callbacks[cid] = event
        return cid, event
874563
def add_callbacks(self, future, callback, errback):
        
        def done(f):
            try:
                res = f.result()
                if callback:
                    callback(res)
            except Exception:
                if errback:
                    errback(create_failure())
        return future.add_done_callback(done)
462125
def _do_update_callback(self, msg):
        """"""
        for callback, sensor in self._updateCallbacks:
            if sensor == msg:
                _LOGGING.debug('Update callback %s for sensor %s',
                               callback, sensor)
                callback(msg)
1249103
def register_callback(self, callback):
        
        if not callable(callback):
            raise ValueError('callback is not a callable')

        self.callbacks.append(callback)
125098
def add_callbacks(self, future, callback, errback):
        
        assert future is not None
        if callback is None:
            assert errback is not None
            future.addErrback(errback)
        else:
            # Twisted allows errback to be None here
            future.addCallbacks(callback, errback)
        return future
439054
def add_delegate(self, callback):
        

        if callback in self._delegate_methods:
            return

        self._delegate_methods.append(callback)
233516
def add_callback(self, cb):
        
        if ((cb in self.callbacks) is False):
            self.callbacks.append(cb)
877661
def __add_callback(self, type_, func, serialised_if_crud=True):
        """"""
        Validation.callable_check(func)
        with self.__callbacks:
            self.__callbacks[type_].append((func, serialised_if_crud))
420786
def add(self, name, func):
        '''  '''
        if name not in self.hooks:
            raise ValueError("Unknown hook name %s" % name)
        was_empty = self._empty()
        self.hooks[name].append(func)
        if self.app and was_empty and not self._empty(): self.app.reset()
219917
def add_listener(event, &block)
      fail ArgumentError, 'must provide callback' unless block_given?
      listeners(event.to_sym).push block
    end
244944
function (callback) {
            var promise = new Promise();
            this.addCallback(function () {
                try {
                    when(isFunction(callback) ? callback.apply(this, arguments) : callback).then(promise);
                } catch (e) {
                    promise.errback(e);
                }
            });

            this.addErrback(function () {
                try {
                    when(isFunction(callback) ? callback.apply(this, arguments) : callback).then(promise);
                } catch (e) {
                    promise.errback(e);
                }
            });
            return promise.promise();
        }
1264076
def add_callback(self, name, func):
        

        if name == 'on_scan':
            events = ['device_seen']
            def callback(_conn_string, _conn_id, _name, event):
                func(self.id, event, event.get('validity_period', 60))
        elif name == 'on_report':
            events = ['report', 'broadcast']
            def callback(_conn_string, conn_id, _name, event):
                func(conn_id, event)
        elif name == 'on_trace':
            events = ['trace']
            def callback(_conn_string, conn_id, _name, event):
                func(conn_id, event)
        elif name == 'on_disconnect':
            events = ['disconnection']
            def callback(_conn_string, conn_id, _name, _event):
                func(self.id, conn_id)
        else:
            raise ArgumentError("Unknown callback type {}".format(name))

        self._adapter.register_monitor([None], events, callback)
301921
def bind(self, callback, sender=None):
        ''''''
        key = (_make_id(callback), _make_id(sender))
        self.callbacks.append((key, callback))
1154311
def on(self, handler):
        """"""
        if not hasattr(handler, '__call__'):
            raise TypeError('handler is not a callable object.')
        self.handlers.add(handler)