FIND YOUR NEXT FEW LINES

Results for “when”

Small, practical examples. Search by task or narrow things down below.

230 snippets foundClear filters
RustErrors & optional values

Keep an optional value only when valid

Keep an optional value only when valid in a complete Rust program using the standard library.

Rust✓ Tested
ReactPerformance & rendering

Mount expensive content only when requested

Mount expensive content only when requested with a small React component and explicit browser behavior.

React✓ Tested
ReactRefs & DOM interaction

Observe when a DOM node is attached

Observe when a DOM node is attached with a small React component and explicit browser behavior.

React✓ Tested
AngularAccessibility & reusable patterns

Preserve input state when tracked records reorder

Preserve input state when tracked records reorder with a standalone Angular component and explicit browser behavior.

Angular✓ Tested
jQueryEvent control

Read a selection when its change event fires

jQuery: A change handler observes the current selected value.

jQuery✓ Tested
C++Ownership & optional values

Read a variant only when it holds the expected type

C++: get_if returns a null pointer rather than throwing for another active alternative.

C++✓ Tested
Arduino / CArrays & embedded state

Reject insertion when a fixed queue is full

Arduino / C: Track a count separately from circular read and write positions.

Arduino / C✓ Tested
RustStrings & Unicode

Remove a prefix only when it matches

Remove a prefix only when it matches in a complete Rust program using the standard library.

Rust✓ Tested
ReactEffects & lifecycle

Rerun an effect when its dependency changes

Rerun an effect when its dependency changes with a small React component and explicit browser behavior.

React✓ Tested
jQueryGetting Started

Respond when a select value changes

jQuery: Learn how to respond when a select value changes in a complete browser example.

jQuery✓ Tested
GoGetting Started

Run cleanup when a function returns

Run cleanup when a function returns using a complete Go program with explicit sample inputs.

Go✓ Tested
ReactEffects & lifecycle

Skip synchronization when a feature is disabled

Skip synchronization when a feature is disabled with a small React component and explicit browser behavior.

React✓ Tested