Code Explainers
Code explainers tagged #polling
rust
use std::collections::HashSet; use std::fs; use std::path::{Path, PathBuf}; use std::thread;
Polling a directory for new files in Rust
polling
filesystem
callbacks
Intermediate
6 steps
go
package logtail import ( "bufio"
How a tail -f follower works in Go
io
context
channels
Intermediate
10 steps
typescript
import { Injectable, inject } from '@angular/core'; import { HttpClient } from '@angular/common/http'; import { Observable, timer, throwError } from 'rxjs'; import { switchMap, takeWhile, filter, take, catchError } from 'rxjs/operators';
Polling a job until it finishes in Angular
rxjs
polling
observables
Intermediate
7 steps
ruby
require 'set' class DirectoryWatcher def initialize(path, pattern: '**/*', interval: 1.0)
Polling for file changes in Ruby
polling
filesystem
diffing
Intermediate
7 steps
javascript
import { useEffect, useState } from 'react'; export function useJobStatus(jobId, { interval = 3000 } = {}) { const [status, setStatus] = useState('pending');
Polling a job status with a React hook
custom-hooks
polling
cleanup
Intermediate
8 steps
php
<?php namespace App\Http\Controllers;
Streaming job progress with SSE in Laravel
server-sent-events
streaming
polling
Advanced
8 steps
python
import os import time from pathlib import Path
Polling a directory for file changes in Python
polling
filesystem
set-operations
Intermediate
8 steps
typescript
interface PollOptions<T> { intervalMs?: number; timeoutMs?: number; signal?: AbortSignal;
A cancellable polling helper in TypeScript
polling
async-await
abortsignal
Intermediate
9 steps
javascript
async function pollJobUntilComplete(jobId, { interval = 2000, timeout = 60000, signal } = {}) { const deadline = Date.now() + timeout; while (true) {
Polling a job until it finishes in JavaScript
polling
async-await
abortsignal
Intermediate
6 steps