Register to receive events until the handler function returns true.
192444
function until(emitter, eventName, handler, context) {
  handler = context ? handler.bind(context) : handler;
  let wrapper = function untilHandler(event) {
    if (handler(event))
      emitter.removeEventListener(eventName, untilHandler);
  };
  emitter.addEventListener(eventName, wrapper);
  return wrapper;
}
958168
def wait_for(conditions)
    unless WebkitRemote::Event.can_receive? self, conditions
      raise ArgumentError, "Cannot receive event with #{conditions.inspect}"
    end

    events = []
    each_event do |event|
      events << event
      break if event.matches?(conditions)
    end
    events
  end
763709
public final boolean register(final SelectableChannel channel, final EventsHandler handler)
    {
        return register(channel, handler, IN | OUT | ERR);
    }
499439
function(name, registerCallback){
      if($bridge['registerHandler']){

        setTimeout(function(){
          $bridge.registerHandler(name,registerCallback)
        },bridgeConfig.bridgeWebViewDelay)

      }else{
        console.log("don't built-in WebView invoking ",name,'{registerHandler}')
      }
    }
617911
function waitFor (event, listener, context, wait) {
    var timeout;
    if (!wait) {
        throw new Error("[FATAL] waitFor called without wait time");
    }
    var handler = function () {
        clearTimeout(timeout);
        listener.apply(context, arguments);
    };
    timeout = setTimeout(function () {
        this.off(event, handler, context);
        listener.call(context, "timeout");
    }.bind(this), wait);
    this.once(event, handler, context);
}
1355993
function(handler) {
      var t = this;
      if (t.monitor && t.monitor.isConnected()) {
        setTimeout(function(){handler(t.monitor);},0);
      }
      else {
        t.connectHandlers.push(handler);
      }
    }
963122
def listen_to_event_updates():
    """"""
    def callback(event):
        print('Event:', event)

    client.create_event_subscription(instance='simulator', on_data=callback)

    sleep(5)
392658
function (event, query, handler, context) {
        return on(this, event, query, handler, context, true);
    }
252683
def event_handler(self):
        """"""

        if not self._notify_queue:
            LOG.error('event_handler: no notification queue for %s',
                      self._service_name)
            return

        LOG.debug('calling event handler for %s', self)
        self.start()
        self.wait()
1144339
function registerListeners() {
  const exit = function exit(signal) {
    console.log(chalk.bgBlack.yellow(`Received ${signal} => Exiting`))
    process.exit()
  }
  const SIGABRT = 'SIGABRT'
  const SIGHUP = 'SIGHUP'
  const SIGINT = 'SIGINT'
  const SIGQUIT = 'SIGQUIT'
  const SIGTERM = 'SIGTERM'

  process.on(SIGABRT, () => exit(SIGABRT))
  process.on(SIGHUP, () => exit(SIGHUP))
  process.on(SIGINT, () => exit(SIGINT))
  process.on(SIGQUIT, () => exit(SIGQUIT))
  process.on(SIGTERM, () => exit(SIGTERM))
}
966870
def trigger(self, event: str, **kwargs: Any) -> None:
        """"""
        event = event.upper()
        for func in self._event_handlers[event]:
            self.loop.create_task(func(**kwargs))
        # This will unblock anyone that is awaiting on the next loop update,
        # while still ensuring the next `await client.wait(event)` doesn't
        # immediately fire.
        async_event = self._events[event]
        async_event.set()
        async_event.clear()
1347688
@Handler(channels = Self.class)
    public void onRegistered(NioRegistration.Completed event)
            throws InterruptedException, IOException {
        NioHandler handler = event.event().handler();
        if (!(handler instanceof TcpChannelImpl)) {
            return;
        }
        if (event.event().get() == null) {
            fire(new Error(event, "Registration failed, no NioDispatcher?",
                new Throwable()));
            return;
        }
        TcpChannelImpl channel = (TcpChannelImpl) handler;
        channel.registrationComplete(event.event());
        channel.downPipeline()
            .fire(new Connected(channel.nioChannel().getLocalAddress(),
                channel.nioChannel().getRemoteAddress()), channel);
    }
1269975
def trigger(self, *args, **kwargs):
        """"""
        for h in self.handlers:
            h(*args, **kwargs)
42854
function once(eventName, handler, context, args) {
    this.on(eventName, handler, context, args, true);
}
637687
def process_event(event_filter, callback, timeout_callback, timeout, args,
                      start_time=None):
        
        try:
            events = event_filter.get_all_entries()
            if events:
                callback(events[0], *args)
                return True

        except (ValueError, Exception) as err:
            # ignore error, but log it
            logger.debug(f'Got error grabbing keeper events: {str(err)}')

        if timeout:
            elapsed = int(datetime.now().timestamp()) - start_time
            if elapsed > timeout:
                if timeout_callback:
                    timeout_callback(*args)
                else:
                    callback(None, *args)

                return True

        return False
689316
def _register_handler(event, fun, external=False):
    """"""
    registry = core.HANDLER_REGISTRY
    if external:
        registry = core.EXTERNAL_HANDLER_REGISTRY

    if not isinstance(event, basestring):
        # If not basestring, it is a BaseEvent subclass.
        # This occurs when class methods are registered as handlers
        event = core.parse_event_to_name(event)

    if event in registry:
        registry[event].append(fun)
    else:
        registry[event] = [fun]
    return fun
441952
async def handler(event):
    """"""
    query = urllib.parse.quote(event.pattern_match.group(1))
    await asyncio.wait([
        event.delete(),
        event.respond(SEARCH.format(query), reply_to=event.reply_to_msg_id)
    ])