rx_flutter_plugin 1.1.1

  • Readme
  • Changelog
  • Example
  • Installing
  • 79

RxFlutterPlugin #

A flutter plugin to bridge RxJava & RxSwift to Dart streams.

Getting Started #

Add this plugin to your flutter application through your pubspec.yaml

dependencies:
    rx_flutter_plugin: ^x.y.z

Opening a platform channel #

Flutter

final channel = new RxFlutterMethodChannel("custom_channel_name");

Android (Kotlin)

val channel = RxFlutterMethodChannel("custom_channel_name", binaryMesseger)
//You can pass in anything that extends FlutterActivity for the binaryMessenger argument. Will be removed in future releases.

Connection your observables #

*Note: All arguments and return values from observables must follow the supported data types for platform channels.

Observables #

Android

channel.addObservable<T>(
                "method_A",
                { argumentsFromFlutter: T ->
                    //Return an ObservableSource<*>
                    return@addObservable Observable.just(1)
                }
        )

Flutter

channel.getObservable(
    "method_A",
    {
        "argument_key_1": "argument_value_1"
    }
)

Singles #

Android

channel.addSingle<T>(
                "method_b",
                { argumentsFromFlutter: T ->
                    //Return a SingleSource<*>
                    return@addSingle Single.just(1)
                }
        )

Flutter

channel.getSingle(
    "method_B",
    {
        "argument_key_1": "argument_value_1"
    }
)

Completables #

Android

channel.addCompletable<T>(
                "method_C",
                { argumentsFromFlutter: T ->
                    //Return a CompletableSource
                    return@addCompletable Completable.complete()
                }
        )

Flutter

channel.getCompletable(
    "method_C",
    {
        "argument_key_1": "argument_value_1"
    }
)

Error Propagation #

How to handle exceptions / errors thrown from the native platforms. When adding the observable source, the errorHandler parameter allows you to pass in a block that accepts a Throwable/Error argument and convert that into a payload (needs to conform to supported data types) that will be a member variable of the ObservableThrownException thrown in Dart.

Android

channel.addCompletable<T>(
                "method_C",
                { argumentsFromFlutter: T ->
                    //Return a CompletableSource
                    return@addCompletable Completable.complete()
                }, 
                { t: Throwable ->
                    return@addObservable hashMapOf(
                            "errorMessage" to t.message
                    )
                }
        )

1.0.0 #

  • Added ErrorHandler to map payloads returned from native Rx subscriptions throwing an error to Dart exceptions.

example/README.md

rx_flutter_plugin_example #

Demonstrates how to use the rx_flutter_plugin plugin.

Getting Started #

This project is a starting point for a Flutter application.

A few resources to get you started if this is your first Flutter project:

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  rx_flutter_plugin: ^1.1.1

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:rx_flutter_plugin/rx_flutter_plugin.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
59
Health:
Code health derived from static analysis. [more]
98
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
79
Learn more about scoring.

We analyzed this package on Oct 16, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.5.1
  • pana: 0.12.21
  • Flutter: 1.9.1+hotfix.4

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health suggestions

Fix lib/src/logger.dart. (-0.50 points)

Analysis of lib/src/logger.dart reported 1 hint:

line 44 col 10: This function has a return type of 'String', but doesn't end with a return statement.

Fix lib/src/observable_action.dart. (-0.50 points)

Analysis of lib/src/observable_action.dart reported 1 hint:

line 16 col 10: This function has a return type of 'String', but doesn't end with a return statement.

Fix lib/src/observable_callback.dart. (-0.50 points)

Analysis of lib/src/observable_callback.dart reported 1 hint:

line 20 col 10: This function has a return type of 'String', but doesn't end with a return statement.

Fix additional 9 files with analysis or formatting issues. (-1 points)

Additional issues in the following files:

  • lib/src/rx_flutter_method_channel.dart (1 hint)
  • lib/src/stream_type.dart (1 hint)
  • lib/rx_flutter_plugin.dart (Run flutter format to format lib/rx_flutter_plugin.dart.)
  • lib/src/exception_handler.dart (Run flutter format to format lib/src/exception_handler.dart.)
  • lib/src/exceptions.dart (Run flutter format to format lib/src/exceptions.dart.)
  • lib/src/field_names.dart (Run flutter format to format lib/src/field_names.dart.)
  • lib/src/observable_registration.dart (Run flutter format to format lib/src/observable_registration.dart.)
  • lib/src/observable_stream_controller.dart (Run flutter format to format lib/src/observable_stream_controller.dart.)
  • lib/src/utils.dart (Run flutter format to format lib/src/utils.dart.)

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.7
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test