Skip to main content

task_once

Function task_once 

Source
pub fn task_once(
    view: &ViewHandle,
    priority: TaskPriority,
    file: &str,
    line: i64,
    action: impl Fn() + Send + Sync + 'static,
) -> ViewHandle
Expand description

Apply .task { … } — the spelling with no id:.

A different modifier from task, not a default-argument version of it: that one builds _TaskValueModifier2<ID> and re-runs when the id changes, this one builds _TaskModifier2 and runs once. _TaskModifier2 is not generic, so there are no generic words to spill.

The name carries the call site — SwiftUI records View.task @ file:line — so a value comparison against a reference only agrees if the caller passes the reference’s own file and line, which is why they are parameters.