Documentation / dataflow-async / com.femastudios.dataflow.async / Attribute / transformWithPrevious
Go to reference

transformWithPrevious

open fun <O> transformWithPrevious(transform: WorkContext.(previous: O?, T) -> O): Attribute<O>

Like Attribute.transform, but the transform function also accepts the previous transformed value.

The first time the transform function is called, the previous value is null.

Please note that it's not guaranteed that the transform function will be called when there are no listeners attached to the returned Attribute. If you want the transform function to be called each time the original Attribute changes, you can use transformWithPrevious(..., allowLaziness = false)


open fun <O> transformWithPrevious(transform: WorkContext.(previous: O?, T) -> O, flowStrategy: FlowStrategy = TRANSFORM_DEFAULT_FLOW_STRATEGY, allowLaziness: Boolean): Attribute<O>

Like Attribute.transform, but the transform function also accepts the previous transformed value.

The first time the transform function is called, the previous value is null.

If allowLaziness is true, it's not guaranteed that the transform function will be called when there are no listeners attached to the returned Attribute. If you want the transform function to be called each time the original Attribute changes, you can use allowLaziness = false