Code Explainers

Code explainers tagged #event-driven

javascript
const zxcvbn = require('zxcvbn');
 
const STRENGTH_LABELS = ['Very weak', 'Weak', 'Fair', 'Strong', 'Very strong'];
const STRENGTH_COLORS = ['#d64545', '#e0803c', '#d9c94c', '#5aa84f', '#2f8f3a'];

Building a live password strength meter

debounce closures dom-events
Intermediate 8 steps
java
@Component
required to import
public class OutboxEventPublisher {
 

The transactional outbox pattern in Spring

transactional-outbox event-driven reliability
Advanced 7 steps
typescript
import {
  WebSocketGateway,
  WebSocketServer,
  SubscribeMessage,

Building a real-time chat gateway in NestJS

websockets real-time socket.io
Intermediate 8 steps
java
@RestController
@RequestMapping("/api/notifications")
public class NotificationStreamController {
 

Server-Sent Events per user in Spring

server-sent-events concurrency event-driven
Advanced 8 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
php
<?php
 
namespace App\Events;
 

A priority event dispatcher in PHP

observer-pattern callbacks priority-ordering
Intermediate 8 steps
java
@Service
public class OrderService {
 
    private final OrderRepository orderRepository;

Decoupling side effects with Spring events

event-driven transactions decoupling
Intermediate 8 steps
python
from django.conf import settings
from django.contrib.auth import get_user_model
from django.core.mail import EmailMultiAlternatives
from django.db.models.signals import post_save

Sending a welcome email with Django signals

signals email user-activation
Intermediate 8 steps
javascript
const transitions = {
  cart: { checkout: 'shipping' },
  shipping: { submitAddress: 'payment', back: 'cart' },
  payment: { submitPayment: 'review', back: 'shipping' },

A finite state machine for checkout flow

state-machine event-driven data-driven-design
Intermediate 7 steps