Code Explainers

Code explainers tagged #context

go
package middleware
 
import (
	"context"

A deadline-enforcing HTTP middleware in Go

middleware context goroutines
Advanced 7 steps
go
package logbuffer
 
import (
	"bufio"

A buffered logger with background flushing in Go

concurrency buffering context
Intermediate 8 steps
go
package storage
 
import (
	"context"

A SQLite-backed order store in Go

database/sql sqlite error-wrapping
Intermediate 7 steps
javascript
import { createContext, useContext, useState, useId } from "react";
 
const AccordionContext = createContext(null);
const ItemContext = createContext(null);

Building a compound Accordion in React

context compound-components state-management
Intermediate 8 steps
javascript
import { createContext, useContext, useEffect, useState, useCallback } from 'react';
 
const ThemeContext = createContext(null);
 

Building a theme provider with React Context

context hooks dark-mode
Intermediate 9 steps
go
package middleware
 
import (
	"context"

How a request-timeout middleware works in Gin

middleware context goroutines
Advanced 6 steps
go
package main
 
import (
	"context"

Graceful shutdown for a Gin server in Go

graceful-shutdown signals goroutines
Intermediate 6 steps
javascript
import { createContext, useContext, useReducer } from "react";
 
const WizardContext = createContext(null);
 

Building a form wizard with Context in React

context reducer state-management
Intermediate 10 steps
javascript
import { createContext, useContext, useReducer } from 'react';
 
const CartContext = createContext(null);
 

Building a shopping cart with Context in React

state management reducer context
Intermediate 10 steps
go
package httpx
 
import (
	"net/http"

A retrying HTTP transport in Go

http middleware retry
Intermediate 8 steps
go
package scheduler
 
import (
	"context"

A context-aware heartbeat ticker in Go

concurrency channels context
Intermediate 5 steps
go
package fetch
 
import (
	"context"

Concurrent API fetches with errgroup in Go

concurrency goroutines error-handling
Intermediate 8 steps
go
package pipeline
 
import (
	"context"

A cancelable worker pool in Go

concurrency channels worker-pool
Advanced 8 steps
go
package main
 
import (
	"context"

Graceful HTTP shutdown in Go

graceful-shutdown signals goroutines
Intermediate 8 steps
go
package retry
 
import (
	"context"

Retry with exponential backoff in Go

retry exponential-backoff jitter
Intermediate 8 steps