Send pending events.

When the status is changed during a save operation, all the "after" events must be sent after the owner model has been saved.
This method is invoked on events ActiveRecord::EVENT_AFTER_UPDATE and ActiveRecord::EVENT_AFTER_INSERT.
3328
private function firePendingEvents()
	{
		if ( ! empty($this->_pendingEvents)) {
			foreach ($this->_pendingEvents as $event) {
				$this->owner->trigger($event->name, $event);
			}
			$this->_pendingEvents = [];

			if ( $this->getStatusAccessor() != null) {
				$this->_statusAccessor->commitStatus($this->owner);
			}
		}
	}
207102
def events(self, *events):
        
        return self.send_events(self.create_event(e) for e in events)
758485
public function onUpdate() {
    
    if (file_exists($this->savedTimestampPath)) {
      $readTimestamp = file_get_contents($this->savedTimestampPath);
      if ($readTimestamp != $this->savedTimestamp) {
        foreach ($this->clients as $sendto) {
          $sendto->send($readTimestamp);
        }
        $this->savedTimestamp = $readTimestamp;
      }
    }
    
  }
1289789
def model_post_delete(sender, instance, **kwargs):
    

    if sender._meta.app_label == 'rest_framework_reactive':
        # Ignore own events.
        return

    def notify():
        table = sender._meta.db_table
        notify_observers(table, ORM_NOTIFY_KIND_DELETE, instance.pk)

    transaction.on_commit(notify)
1330001
public function onYiiEvent()
    {
        Event::on(ActiveRecord::className(), ActiveRecord::EVENT_INIT, function ($event) {
            /** @var ActiveRecord $model */
            $model = $event->sender;
            $model->getTableSchema();
        });
    }
695187
def save_event(event)
      method = event.new_event? ? :post : :put
      body = event.use_quickadd? ? nil : event.to_json
      notifications = "sendNotifications=#{event.send_notifications?}"
      query_string =  if event.use_quickadd?
                        "/quickAdd?#{notifications}&text=#{event.title}"
                      elsif event.new_event?
                        "?#{notifications}"
                      else # update existing event.
                        "/#{event.id}?#{notifications}"
                      end

      send_events_request(query_string, method, body)
    end
326704
def post_save_event_listener(sender, instance, created):
    """"""
    if not instance._meta.event_ready:
        return

    if created:
        instance.create_creation_event()
    else:
        instance.create_update_event()

    # Reset the original key
    instance._original = None
875062
def async_update(self, event):
        
        self.update_attr(event.get('state', {}))
        super().async_update(event)
300594
def trigger_async(channels, event_name, data, params = {})
      post_async('/events', trigger_params(channels, event_name, data, params))
    end
1184054
async def save(self):
        

        if hasattr(self, "before_save"):
            self.before_save()

        query = r.table(self.table_name)

        if self._state.get("id"):
            query = query \
                .get(self._state.get("id")) \
                .update(self.__db_repr, return_changes=True)
        else:
            query = query \
                .insert(self.__db_repr, return_changes=True)

        resp = await query.run(await conn.get())

        try:
            changes = resp["changes"]

            if len(changes) > 0:
                self.wrap(resp["changes"][0]["new_val"])
        except KeyError:
            raise UnexpectedDbResponse()

        if resp["skipped"] > 0:
            raise UnexpectedDbResponse(
                "Model with id `%s` not found in the database." %
                self._state.get("id"))

        return self
702004
public function save()
	{
		if ($this->hasEventHandler('onBeforeSave')) {
			$this->onBeforeSave(new CEvent($this));
		}
		$this->flush();
		if ($this->hasEventHandler('onAfterSave')) {
			$this->onAfterSave(new CEvent($this));
		}
	}
81960
@Override
    public void send(Event event) {
        if (!closed) {
            queue.add(withPayload(new EventSubmitter(id, event)));
        }
    }
961402
public function onBeforeWrite()
    {
        parent::onBeforeWrite();
        $owner = $this->owner;
        if (!$owner->ID) {
            // first write
            $owner->updatepresets = true;
        }
    }
884344
private void sendEvents(EventHolder event) {
    // Only send events to the client if this server is the leader.
    if (server.isLeader()) {
      eventExecutor.execute(() -> {
        PublishRequest request = PublishRequest.builder()
            .withSession(sessionId().id())
            .withEventIndex(event.eventIndex)
            .withPreviousIndex(event.previousIndex)
            .withEvents(event.events)
            .build();

        log.trace("Sending {}", request);
        protocol.publish(memberId(), request);
      });
    }
  }
38574
function send() {
    var args = slice.call(arguments), events = this.events, handled;

    if (!this.__isCurrent__) {
      throw new Error('State#send: attempted to send an event to a state that is not current: ' + this);
    }

    if (this === this.root()) {
      trace.call(this, 'State: [EVENT]  : ' + args[0]);
    }

    handled = this.concurrent ? sendConcurrent.apply(this, arguments) :
      sendClustered.apply(this, arguments);

    if (!handled && typeof events[args[0]] === 'function') {
      this.__isSending__ = true;
      handled = !!events[args[0]].apply(this, args.slice(1));
      this.__isSending__ = false;
    }

    if (!this.superstate) { transition.call(this); }

    return handled;
  }
411647
def _send_event_to_all(self, action, event):
        
        for project_listeners in self._listeners.values():
            for listener in project_listeners:
                listener.put_nowait((action, event, {}))
869313
def manager_post_save_handler(sender, instance, created, **kwargs):
    """"""
    if instance.status == Data.STATUS_DONE or instance.status == Data.STATUS_ERROR or created:
        # Run manager at the end of the potential transaction. Otherwise
        # tasks are send to workers before transaction ends and therefore
        # workers cannot access objects created inside transaction.
        transaction.on_commit(lambda: commit_signal(instance.id))