react_async 0.1.0

  • README.md
  • Installing
  • Versions
  • new60

react_async

pub package

Provides components for building asynchronous user interfaces out of dart-react.

This makes easy to adopt the BloC pattern and share a major part of your Flutter application logic with a website since the components are inspired by their Flutter equivalent.

Quickstart

The example below shows you how to use StreamBuilder and FutureBuilder.

import 'dart:async';
import 'dart:html';
import 'package:react_async/async.dart';
import 'package:react/react.dart';
import 'package:react/react_client.dart' as react_client;
import 'package:react/react_dom.dart' as react_dom;

/// An example model object that exposes a `Future` and a
/// `Stream`. Our components will be able to observe them,
/// and update in accordingly.
class Model {
  Future<String> future() async {
    await Future.delayed(Duration(seconds: 4));
    return "Finished!";
  }

  Stream<String> stream() async* {
    await Future.delayed(Duration(seconds: 1));
    yield "3";
    await Future.delayed(Duration(seconds: 1));
    yield "2";
    await Future.delayed(Duration(seconds: 1));
    yield "1";
    await Future.delayed(Duration(seconds: 1));
    yield "Finished!";
  }
}

/// An example component that will be updated asynchronously 
/// from our model.
class HomeComponent extends Component {
  final Model model = Model();

  /// A component instance that will be refreshed at the end
  /// of the model's future execution.
  dynamic _fromFuture() => FutureBuilder<String>(
    initialData: "Ready...",
    future: this.model.future(),
    builder: (s) => b({}, s.data));

  /// A component instance that will be refreshed on each update
  /// from the model's stream.
  dynamic _fromStream() => StreamBuilder<String>(
    initialData: "Ready...",
    stream: this.model.stream(),
    builder: (s) => b({}, s.data));

  @override
  render() => div({}, [
    div({}, [ "Future:", _fromFuture()]),
    div({}, [ "Stream:", _fromStream()]),
  ]);
}

var Home = registerComponent(() => HomeComponent());

main() {
  react_client.setClientConfiguration();
  react_dom.render(Home({}), querySelector('#react_mount_point'));
}

Issues

Please file any issues, bugs, or feature requests on GitHub.

Use this package as a library

1. Depend on it

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


dependencies:
  react_async: ^0.1.0

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter packages get

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

3. Import it

Now in your Dart code, you can use:


import 'package:react_async/async.dart';
import 'package:react_async/base/hash_codes.dart';
import 'package:react_async/base/renderers.dart';
import 'package:react_async/base/snapshot.dart';
import 'package:react_async/builders/future_builder.dart';
import 'package:react_async/builders/stream_builder.dart';
  
Version Uploaded Documentation Archive
0.1.0 Oct 22, 2018 Go to the documentation of react_async 0.1.0 Download react_async 0.1.0 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
28
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
80
Overall:
Weighted score of the above. [more]
60
Learn more about scoring.

We analyzed this package on Nov 14, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0
  • pana: 0.12.6

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in libraries.

Health suggestions

Format lib/async.dart.

Run dartfmt to format lib/async.dart.

Format lib/base/hash_codes.dart.

Run dartfmt to format lib/base/hash_codes.dart.

Format lib/base/renderers.dart.

Run dartfmt to format lib/base/renderers.dart.

Fix additional 3 files with analysis or formatting issues.

Additional issues in the following files:

  • lib/base/snapshot.dart (Run dartfmt to format lib/base/snapshot.dart.)
  • lib/builders/future_builder.dart (Run dartfmt to format lib/builders/future_builder.dart.)
  • lib/builders/stream_builder.dart (Run dartfmt to format lib/builders/stream_builder.dart.)

Maintenance issues and suggestions

Maintain CHANGELOG.md. (-20 points)

Changelog entries help clients to follow the progress in your code.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
meta ^1.1.6 1.1.6
react ^4.5.0 4.5.0
Transitive dependencies
js 0.6.1+1
Dev dependencies
build_runner >=0.8.10 <2.0.0
build_web_compilers >=0.3.6 <0.5.0