Add an observer with priority and callble
489160
def add(self, priority, observer, callble):
        
        #if observer is not None:
        ins = 0
        for pr, _, _ in self:
            if priority > pr:
                break
            ins += 1
        self._poc.insert(ins, (priority, weakref.ref(observer), callble))
334501
def notify_to(observers, *args)
      if block_given? && !args.empty?
        raise ArgumentError.new 'cannot give arguments and a block'
      end
      observers.each do |observer, function|
        args = yield if block_given?
        observer.send(function, *args)
      end
    end
771782
public function attach($eventType, $callable, $priority = 10)
    {
        if (!isset(self::$listener[$eventType])) {
            self::$listener[$eventType] = new SplPriorityQueue();
        }

        self::$listener[$eventType]->insert($callable, $priority);

        return $this;
    }
1106113
def observe(self, event, fn):
        
        iscoroutine = asyncio.iscoroutinefunction(fn)
        if not iscoroutine and not isfunction(fn):
            raise TypeError('paco: fn param must be a callable '
                            'object or coroutine function')

        observers = self._pool.get(event)
        if not observers:
            observers = self._pool[event] = []

        # Register the observer
        observers.append(fn if iscoroutine else coroutine_wrapper(fn))
763452
def on_remove(self, callable_):
        
        self.model.add_observer(
            callable_, self.entity_type, 'remove', self.entity_id)
1072882
function addToQueue( callback, prioritize, seed ) {
	if ( prioritize ) {
		config.queue.splice( priorityCount++, 0, callback );
	} else if ( seed ) {
		if ( !unitSampler ) {
			unitSampler = unitSamplerGenerator( seed );
		}

		// Insert into a random position after all prioritized items
		const index = Math.floor( unitSampler() * ( config.queue.length - priorityCount + 1 ) );
		config.queue.splice( priorityCount + index, 0, callback );
	} else {
		config.queue.push( callback );
	}
}
945040
def extend(self, other):
        """"""
        index = len(self)
        length = 0
        for length, element in enumerate(other, 1):
            super(ObservableList, self).append(element)
        if length:
            self._notify_add_at(index, length)
856212
def add_callback(self, fn, *args, **kwargs):
        """"""
        if _debug: IOCB._debug("add_callback(%d) %r %r %r", self.ioID, fn, args, kwargs)

        # store it
        self.ioCallback.append((fn, args, kwargs))

        # already complete?
        if self.ioComplete.isSet():
            self.trigger()
1321417
protected void addObserver (Object obs)
    {
        if (_observers == null) {
            _observers = ObserverList.newFastUnsafe();
        }
        _observers.add(obs);
    }
941244
private <T extends Throwable> T onAbort(UploadObjectObserver observer, T t) {
        observer.onAbort();
        return t;
    }
1363585
def observed(cls, _func):
        

        def wrapper(*args, **kwargs):
            self = args[0]
            assert(isinstance(self, Observable))

            self._notify_method_before(self, _func.__name__, args, kwargs)
            res = _func(*args, **kwargs)
            self._notify_method_after(self, _func.__name__, res, args, kwargs)
            return res

        return wrapper
207101
void observe(FolderObserver observer) {
    synchronized (idleMutex) {
      this.observer = observer;
      pushedData = new PushedData();
      idleAcknowledged.set(false);
    }
  }
1359489
public function on($event, $callable, $important = false)
    {
        Argument::i()
            //argument 1 must be string
            ->test(1, 'string')
            //argument 2 must be callable or null
            ->test(2, 'callable', 'null')
            //argument 3 must be boolean
            ->test(3, 'bool');

        $id = $this->getId($callable);

        //set up the observer
        $observer = array($event, $id, $callable);

        //if this is important
        if ($important) {
            //put the observer on the top of the list
            array_unshift($this->observers, $observer);
            return $this;
        }

        //add the observer
        $this->observers[] = $observer;
        return $this;
    }
1028223
public function on(string $eventName, callable $callBack, int $priority = 100)
    {
        if (!isset($this->listeners[$eventName])) {
            $this->listeners[$eventName] = [
                true,  // If there's only one item, it's sorted
                [$priority],
                [$callBack]
            ];
        } else {
            $this->listeners[$eventName][0] = false; // marked as unsorted
            $this->listeners[$eventName][1][] = $priority;
            $this->listeners[$eventName][2][] = $callBack;
        }
    }
380101
async def observer_orm_notify(self, message):
        """"""

        @database_sync_to_async
        def get_observers(table):
            # Find all observers with dependencies on the given table.
            return list(
                Observer.objects.filter(
                    dependencies__table=table, subscribers__isnull=False
                )
                .distinct('pk')
                .values_list('pk', flat=True)
            )

        observers_ids = await get_observers(message['table'])

        for observer_id in observers_ids:
            await self.channel_layer.send(
                CHANNEL_WORKER, {'type': TYPE_EVALUATE, 'observer': observer_id}
            )
60449
public function hook($event, callable $callback, $priority = 10)
    {
        $this->app->hook($event, $callback, $priority);
    }
75650
function on(string $event, $callback, int $priority = 0): void
    {
        $this->getEventEmitter()->on($event, $callback, $priority);
    }