Manage the codecasting stream. Wait for code events (for each panel) then
update the appropriate panel
969740
function codecastStream() {
    if (!(jsbin && jsbin.panels && jsbin.panels.panels)) return;
    var editors = jsbin.panels.panels;

    function setCode(event) {
      var panelId = event.type;
      if (!editors[panelId]) return;
      var cursor = editors[panelId].editor.getCursor();
      editors[panelId].setCode(event.data);
      editors[panelId].editor.setCursor(cursor);
    }

    // Update the url when the revision is bumped
    es.addEventListener('bump-revision', function (event) {
      window.location.pathname = cleanPath(event.data) + '/edit';
    });
    // on data, update the panels, which will cause an automatic render
    es.addEventListener('css', setCode);
    es.addEventListener('javascript', setCode);
    es.addEventListener('html', setCode);
  }
601727
def listen(self):
        
        with Consumer(self.connection, queues=self.queue, on_message=self.on_message,
                      auto_declare=False):
            for _ in eventloop(self.connection, timeout=1, ignore_timeouts=True):
                    pass
1234137
@Override
  @SuppressWarnings("unchecked")
  public Task<ChangeEventT> nextEvent() throws IOException {
    return dispatcher.dispatchTask(new Callable<ChangeEventT>() {
      @Override
      public ChangeEventT call() throws Exception {
        final StitchEvent<ChangeEventT> nextEvent =
            (StitchEvent<ChangeEventT>) getInternalStream().nextEvent();

        if (nextEvent == null) {
          return null;
        }
        if (nextEvent.getError() != null) {
          dispatchError(nextEvent);
          return null;
        }
        if (nextEvent.getData() == null) {
          return null;
        }

        return nextEvent.getData();
      }
    });
  }
448785
def waitUntilFinished(self):
        
        QtCore.QCoreApplication.processEvents()
        while self.isLoading():
            QtCore.QCoreApplication.processEvents()
454611
function(node) {
			this.currentNode = node;// Updates the code path.
			// And emits onCodePathStart/onCodePathSegmentStart events.
			processCodePathToExit(this, node);

			// Emits node events.
			this.original.leaveNode(node);

			// Emits the last onCodePathStart/onCodePathSegmentStart events.
			postprocess(this, node);

			this.currentNode = null;
		}
45262
def _register_event_listeners(self, cls):
        
        event.listen(cls, 'after_insert', self._new_listener)
        event.listen(cls, 'after_update', self._update_listener)
        event.listen(cls, 'after_delete', self._delete_listener)
419335
void storeNextEvent() {
    try {
      if (currentStream != null && currentStream.isOpen()) {
        final StitchEvent<ChangeEvent<BsonDocument>> event = currentStream.nextEvent();
        if (event == null) {
          return;
        }

        if (event.getError() != null) {
          throw event.getError();
        }

        if (event.getData() == null) {
          return;
        }

        logger.debug(String.format(Locale.US,
            "NamespaceChangeStreamListener::stream ns=%s event found: op=%s id=%s",
            nsConfig.getNamespace(), event.getData().getOperationType(), event.getData().getId()));
        nsLock.writeLock().lockInterruptibly();
        try {
          events.put(BsonUtils.getDocumentId(event.getData().getDocumentKey()), event.getData());
        } finally {
          nsLock.writeLock().unlock();
        }

        for (final Callback<ChangeEvent<BsonDocument>, Object> watcher : watchers) {
          watcher.onComplete(OperationResult.successfulResultOf(event.getData()));
        }
      }
    } catch (final InterruptedException | IOException ex) {
      logger.info(String.format(
          Locale.US,
          "NamespaceChangeStreamListener::stream ns=%s interrupted on "
              + "fetching next event: %s",
          nsConfig.getNamespace(),
          ex));
      logger.info("stream END – INTERRUPTED");
      Thread.currentThread().interrupt();
    } catch (final Exception ex) {
      // TODO: Emit error through DataSynchronizer as an ifc
      logger.error(String.format(
          Locale.US,
          "NamespaceChangeStreamListener::stream ns=%s exception on fetching next event: %s",
          nsConfig.getNamespace(),
          ex), ex);
      logger.info("stream END – EXCEPTION");
      final boolean wasInterrupted = Thread.currentThread().isInterrupted();
      this.close();
      if (wasInterrupted) {
        Thread.currentThread().interrupt();
      }
    }
  }
649466
private <T> void manageSubscription(EventStream<T> stream, Consumer<T> consumer) {
        manageSubscription(stream.subscribe(consumer));
    }
207482
protected void dispatchQueuedEvents() {
    // don't dispatch if we're already dispatching, that would allow reentrancy and out-of-order events. Instead, leave
    // the events to be dispatched after the in-progress dispatch is complete.
    if (isDispatching.get()) {
      return;
    }

    isDispatching.set(true);
    try {
      while (true) {
        EventWithHandler eventWithHandler = eventsToDispatch.get().poll();
        if (eventWithHandler == null) {
          break;
        }

        if (eventWithHandler.handler.isValid()) {
          dispatch(eventWithHandler.event, eventWithHandler.handler);
        }
      }
    } finally {
      isDispatching.set(false);
    }
  }
1061400
def paintEvent(self, e):
        
        self._update_visible_blocks(e)
        super(CodeEdit, self).paintEvent(e)
        self.painted.emit(e)
536608
def focusInEvent(self, event):
        
        self.focused_in.emit(event)
        super(CodeEdit, self).focusInEvent(event)
1267655
def enable_events(self, event_callback=None) -> None:
        """"""
        self.event = EventManager(event_callback)
        self.stream.event = self.event
808672
function (done) {
        var self = this;
        self.log.debug('NSP: %s', self.nsp);

        async.waterfall([

          function (next) {
            if (!self.nsp) {
              self._request('https://api.box.com/2.0/events', 'GET', next, {
                stream_position: 'now'
              });
            } else {
              next(null, null);
            }
          },
          function (body, next) {
            if (body) {
              self.nsp = body.next_stream_position;
              /**
               * Fires when a stream position has been fixed. All events from here onwards will be captured.
               * @event Connection#"polling.ready"
               */
              self.emit('polling.ready');
            }
            self._request('https://api.box.com/2.0/events', 'OPTIONS', next);
          },
          function (body, next) {
            self._request(body.entries[0].url, 'GET', next, {
              stream_position: self.nsp
            }, null, null, null, null, {
              timeout: 600000,
              num_retries: -1
            });
          },
          function (body, next) {
            self.log.debug(body);
            if (!_.isEmpty(body) && (body.message === 'new_change')) {
              self._request('https://api.box.com/2.0/events', 'GET', next, {
                stream_position: self.nsp
              });
            } else {
              self.log.debug('Refreshing long-poll...');
              next(null, null);
            }
          },
          function (body, next) {
            if (body) {
              self.nsp = body.next_stream_position;
              _.each(body.entries, _.bind(self._trackEvent, self));
            }
            next();
          }
        ], done);
      }
497281
function () {
        function checkUpdate() {
            var current = module.exports.current();
            if (current !== last) {
                last = current;
                events.trigger('update', current);
            }
        }

        // Do not run unless breakpoints are available.
        if (!running && breakpoints.length) {
            running = true;
            global.addEventListener('resize', function () {
                if (!working) {
                    working = true;
                    global.requestAnimationFrame(function () {
                        checkUpdate();
                        working = false;
                    });
                }
            });
        }
        checkUpdate();
    }
1061436
def realtime_updates(self):
        
        # TODO: make this available for every buffer
        logger.info("starting receiving events from docker")
        it = self.d.realtime_updates()
        while True:
            try:
                event = next(it)
            except NotifyError as ex:
                self.ui.notify_message("error when receiving realtime events from docker: %s" % ex,
                                       level="error")
                return
            # FIXME: we should pass events to all buffers
            # ATM the buffers can't be rendered since they are not displayed
            # and hence traceback like this: ListBoxError("Listbox contents too short! ...
            logger.debug("pass event to current buffer %s", self.ui.current_buffer)
            try:
                self.ui.current_buffer.process_realtime_event(event)
            except Exception as ex:
                # swallow any exc
                logger.error("error while processing runtime event: %r", ex)
1003255
private void prepareThreadManager(StreamConfiguration sc) {
    assert(!flacStreamIsOpen);
    if(MAX_THREADED_FRAMES > 0) {
      threadManager = new BlockThreadManager(this);
      threadedFrames = new Frame[MAX_THREADED_FRAMES];
      for(int i = 0; i < MAX_THREADED_FRAMES; i++) {
        threadedFrames[i]  = new Frame(this.streamConfig);
        threadManager.addFrameThread(threadedFrames[i]);
      }
    }
    else {
      threadManager = null;
    }
  }
1292225
@Override
    public synchronized void update(ReceiveStreamEvent evt) {

        Participant participant = evt.getParticipant();    // could be null.
        ReceiveStream stream = evt.getReceiveStream();  // could be null.

        if (evt instanceof RemotePayloadChangeEvent) {
            LOGGER.severe("  - Received an RTP PayloadChangeEvent.");
            LOGGER.severe("Sorry, cannot handle payload change.");

        }
        else if (evt instanceof NewReceiveStreamEvent) {

            try {
                stream = evt.getReceiveStream();
                DataSource ds = stream.getDataSource();

                // Find out the formats.
                RTPControl ctl = (RTPControl) ds.getControl("javax.jmf.rtp.RTPControl");
                if (ctl != null) {
                    LOGGER.severe("  - Received new RTP stream: " + ctl.getFormat());
                }
                else
                    LOGGER.severe("  - Received new RTP stream");

                if (participant == null)
                    LOGGER.severe("      The sender of this stream had yet to be identified.");
                else {
                    LOGGER.severe("      The stream comes from: " + participant.getCNAME());
                }

                // create a player by passing datasource to the Media Manager
                Player p = javax.media.Manager.createPlayer(ds);
                if (p == null)
                    return;

                p.addControllerListener(this);
                p.realize();
                jingleMediaSession.mediaReceived(participant != null ? participant.getCNAME() : "");

                // Notify initialize() that a new stream had arrived.
                synchronized (dataSync) {
                    dataReceived = true;
                    dataSync.notifyAll();
                }

            }
            catch (Exception e) {
                LOGGER.severe("NewReceiveStreamEvent exception " + e.getMessage());
                return;
            }

        }
        else if (evt instanceof StreamMappedEvent) {

            if (stream != null && stream.getDataSource() != null) {
                DataSource ds = stream.getDataSource();
                // Find out the formats.
                RTPControl ctl = (RTPControl) ds.getControl("javax.jmf.rtp.RTPControl");
                LOGGER.severe("  - The previously unidentified stream ");
                if (ctl != null)
                    LOGGER.severe("      " + ctl.getFormat());
                LOGGER.severe("      had now been identified as sent by: " + participant.getCNAME());
            }
        }
        else if (evt instanceof ByeEvent) {

            LOGGER.severe("  - Got \"bye\" from: " + participant.getCNAME());

        }

    }