Code Explainers

Code explainers tagged #pub-sub

java
@Configuration
@EnableWebSocketMessageBroker
public class WebSocketConfig implements WebSocketMessageBrokerConfigurer {
 

Real-time chat over STOMP WebSockets in Spring

websockets stomp messaging
Intermediate 8 steps
ruby
module SlowQueryLogger
  SLOW_QUERY_THRESHOLD_MS = 200.0
  IGNORED_PAYLOAD_NAMES = %w[SCHEMA TRANSACTION].freeze
 

Logging slow SQL queries in Rails

instrumentation logging pub-sub
Intermediate 7 steps
javascript
const express = require('express');
const EventEmitter = require('events');
 
const router = express.Router();

Server-Sent Events with Express

server-sent-events streaming event-emitter
Advanced 8 steps
python
import json
import time
import queue
 

Server-Sent Events streaming in Flask

server-sent-events streaming pub-sub
Advanced 9 steps
rust
use axum::{
    extract::State,
    response::sse::{Event, KeepAlive, Sse},
};

Broadcasting live prices over SSE in Axum

server-sent-events broadcast-channel streams
Advanced 9 steps
typescript
import { Injectable, NotFoundException } from '@nestjs/common';
import { EventEmitter2, OnEvent } from '@nestjs/event-emitter';
import { InjectRepository } from '@nestjs/typeorm';
import { Repository } from 'typeorm';

Decoupling side effects with NestJS events

event-driven decoupling dependency-injection
Intermediate 7 steps
javascript
class EventEmitter {
  constructor() {
    this.listeners = new Map();
  }

Building an EventEmitter in JavaScript

pub-sub closures map
Intermediate 7 steps
ruby
class EventEmitter
  def initialize
    @listeners = Hash.new { |hash, key| hash[key] = [] }
  end

Building an EventEmitter in Ruby

pub-sub closures callbacks
Intermediate 7 steps