events

javascript
// Basic event listener
const button = document.getElementById('myButton');

button.addEventListener('click', function(event) {
  console.log('Button clicked!');
  console.log('Event type:', event.type);

Event handling and event delegation patterns in JavaScript

javascript events event-delegation
by Alex Chang 1 tab
sql
-- Publisher: Send notification
NOTIFY new_order, 'Order #12345 created';

-- Subscriber: Listen for notifications
LISTEN new_order;

PostgreSQL LISTEN/NOTIFY for pub-sub messaging

postgresql listen-notify pub-sub
by Maria Garcia 2 tabs
php
<?php

namespace App\Observers;

use App\Events\PostPublished;
use App\Models\Post;

Laravel model observers for lifecycle hooks

laravel observers eloquent
by Carlos Mendez 2 tabs
python
from django.db.models.signals import post_save
from django.dispatch import receiver
from django.core.mail import send_mail
from .models import User, Profile

Django signals for decoupled event handling

django python signals
by Priya Sharma 2 tabs
typescript
export type EventMap = Record<string, unknown[]>;

type Listener<Args extends unknown[]> = (...args: Args) => void;

export class TypedEmitter<Events extends EventMap> {
  private listeners = new Map<keyof Events, Set<Listener<any>>>();

Type-Safe Event Emitter With Strongly-Typed Listener Payloads in TypeScript

typescript events event-emitter
by codesnips 3 tabs
go
package events

import "encoding/json"

type Envelope struct {
  Type    string          `json:"type"`

Store unstructured JSON safely with json.RawMessage

go json events
by Leah Thompson 1 tab
java
package com.example.demo.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.context.annotation.Bean;

Event-driven architecture with Spring Events

java spring-events event-driven
by David Kumar 4 tabs
javascript
let installed = false;

function notify(message, level = "error") {
  document.dispatchEvent(
    new CustomEvent("flash:show", { detail: { message, level } })
  );

Turbo Drive lifecycle: attach global error handler

rails turbo hotwire
by codesnips 3 tabs
php
<?php

namespace App\Events;

use App\Models\Order;
use Illuminate\Broadcasting\InteractsWithSockets;

Laravel event-driven architecture with listeners

laravel events listeners
by Carlos Mendez 4 tabs
rust
use notify::{Event, RecommendedWatcher, RecursiveMode, Watcher};
use std::path::{Path, PathBuf};
use std::sync::mpsc;

pub fn spawn_watcher(root: &Path) -> notify::Result<(RecommendedWatcher, flume::Receiver<PathBuf>)> {
    let (raw_tx, raw_rx) = mpsc::channel::<notify::Result<Event>>();

Debouncing Rapid Filesystem Events in a Rust Directory Watcher

rust filesystem notify
by codesnips 3 tabs