concept last value in category android

appears as: last value, last values, The last value, last value
RxJava for Android Developers

This is an excerpt from Manning's book RxJava for Android Developers.

In FRP, behavior has a special meaning. In our terminology, it’s an observable that emits the last value it emitted for all new subscribers immediately upon subscription. Some argue that in pure FRP, you have only behaviors. In Rx programming, however, a behavior is just one special kind of an observable, though an extremely useful one.

You can test it by asking, “Are the emitted values of the observable communicating state change or are they one-off events?” Or, “Would the last value the observable emitted be potentially useful in five minutes?” If the answer is yes, you have a real observable that represents reactive state. If no, you’re dealing with an event observable.

In our case, gridObservable represents reactive state. If you reload the view, you can use the last value it emitted to redraw it.

// Reset any existing ValueAnimator.
if (valueAnimator != null) {
  valueAnimator.end();
  valueAnimator = null;
}

// Create a new animator from last value to the new target
valueAnimator =
  ValueAnimator.ofFloat(
    (Float) lastValue, (Float) targetValue
  );

// Track updates and inform the subscribers
valueAnimator.addUpdateListener(...);

// Start the animation!
valueAnimator.start();