Skip to main content

distinct_until_changed

Function distinct_until_changed 

Source
pub fn distinct_until_changed<F>(
    core: &Core,
    binding: &Arc<dyn OperatorBinding>,
    source: NodeId,
    equals: F,
) -> OperatorRegistration
where F: Fn(HandleId, HandleId) -> bool + Send + Sync + 'static,
Expand description

distinctUntilChanged(source, equals) — suppresses adjacent duplicates.

Each input is compared against the previous emitted value via equals. If equal (suppressed), no output. If not equal, emit verbatim and update prev. First-ever input is always emitted.

§Default identity

For Identity-equals (the common case), pass a closure that returns a == b. For deeper comparison (Object.is-style or struct-equal), the binding should deref both handles and call the user’s Fn(T, T) -> bool underneath.