diff --git a/library/src/main/java/com/google/android/material/motion/streams/MotionObservable.java b/library/src/main/java/com/google/android/material/motion/streams/MotionObservable.java index ee06c98..97ec63d 100644 --- a/library/src/main/java/com/google/android/material/motion/streams/MotionObservable.java +++ b/library/src/main/java/com/google/android/material/motion/streams/MotionObservable.java @@ -122,6 +122,28 @@ public static abstract class Predicate { public abstract boolean evaluate(T value); } + /** + * An inline property that can be read into a MotionObservable stream. + */ + public static abstract class InlineReadable { + + /** + * Reads the property's value. + */ + public abstract T read(); + } + + /** + * An inline property that can be written from a MotionObservable stream. + */ + public static abstract class InlineWritable { + + /** + * Writes the property with the given value. + */ + public abstract void write(T value); + } + /** * A light-weight operator builder. *

@@ -194,7 +216,7 @@ public void next(MotionObserver observer, T value) { } /** - * Writes the values from an Observable onto the given target and property. + * Writes the values from an Observable onto the given unscoped property. * * @see The * write() specification @@ -208,4 +230,20 @@ public void next(MotionObserver observer, T value) { } }); } + + /** + * Writes the values from an Observable onto the given inline property. + * + * @see The + * write() specification + */ + public MotionObservable write(final InlineWritable property) { + return operator(new Operation() { + @Override + public void next(MotionObserver observer, T value) { + property.write(value); + observer.next(value); + } + }); + } }