DEV Community

Yang
Yang

Posted on

FlowBinding 1.0

It's been over a year since the initial release of FlowBinding.

Over the last year we've added 4 new artifacts for AndroidX libraries, dropped our minimum SDK all the way back to API 14, introduced a new InitialValueFlow API for widgets that emit state changes, and new API docs.

Today I'm excited share the 1.0 stable release of FlowBinding!

What's new

While the majority of the APIs have remained the same since the first public release (original blogpost) last year, we've made a decent amount of improvements to the library over the last 14 months.

New artifacts

Our focus has been on providing bindings for flowbinding-material which is where most of the new UI widgets are being developed, but we also added 4 new artifacts for AndroidX libraries:

Min SDK 14

Originally the minSdkVersion FlowBinding required was API 21. While this is reasonable for most users, support for lower API levels remains essential for users who are developing for emerging markets (see this tweet for more context).

We've now dropped our minSdkVersion to API 14.

Initial value

For UI widgets that hold a state internally such as the current value of a Slider (a recently added Material Component), our bindings used to provide an optional emitImmediately: Boolean to indicate whether the current value should be emitted immediately when collected:

@CheckResult
@UseExperimental(ExperimentalCoroutinesApi::class)
fun Slider.valueChanges(emitImmediately: Boolean = false): Flow<Float> = callbackFlow {
...
}
Enter fullscreen mode Exit fullscreen mode

The default value of emitImmediately was false which not everyone agrees.

After discussions within the community we've decided to introduce a new InitialValueFlow for the bindings that emit state changes (many thanks to Sven Jacobs for the idea).

An InitialValueFlow emits the current value (state) of the widget immediately upon collection of the Flow.

This effectively changed the previous default value of emitImmediately from false to true, but communicates the behavior more clearly in the type itself.

To skip the initial emission of the current value, call the skipInitialValue() function on the InitialValueFlow:

slider.valueChanges()
    .skipInitialValue()
    .onEach { value ->
        // handle value
    }
    .launchIn(uiScope) // current value won't be emitted immediately
Enter fullscreen mode Exit fullscreen mode

This is also consistent with RxBinding's InitialValueObservable.

New API Docs

FlowBinding has many artifacts and APIs. We now have a new project website that documents all transitive AndroidX dependencies and the bindings available in each artifact, along with new API docs powered by Dokka 1.4.

Alt Text

What's next?

Jetpack Compose is clearly the future of UI development for Android, while FlowBinding specifically targets the current generation of UI toolkits, which isn't going away anytime soon. The material-components-android library is still being actively developed with many new view-based components being added or planned.

Therefore we're planning to continue the work on maintaining AndroidX bindings and adding bindings for the new Material Design Components (e.g. TimePicker) as they become available.

Thanks!

I'd like to thank everyone who has used FlowBinding, reported bugs, made feature requests, participated in discussions or sent PRs in the last 14 months, which all contributed to what we've achieved with the library today!

Top comments (2)

Collapse
 
msfjarvis profile image
Harsh Shandilya

Great work and congratulations for the 1.0 release! The formatting near the top of the post appears to be slightly broken causing the image to not render correctly.

Collapse
 
ychescale9 profile image
Yang

Just fixed. Thanks!