react_redurx 0.1.0

  • README.md
  • Example
  • Installing
  • Versions
  • 38

React-ReduRx

React bindings for ReduRx.

Usage

import 'dart:html' show querySelector;

import 'package:react/react.dart';
import 'package:react/react_client.dart' show setClientConfiguration;
import 'package:react/react_client/react_interop.dart';
import 'package:react/react_dom.dart' show render;
import 'package:react_redurx/react_redurx.dart';
import 'package:redurx/redurx.dart';

final app = registerComponent(() => App());
final foo = registerComponent(() => Foo());

class State {
  State(this.count);
  final int count;

  @override
  String toString() => '{count: $count}';
}

class Increment implements Action<State> {
  State reduce(State state) => State(state.count + 1);
}

class Foo extends Component {
  @override
  ReactElement render() => div({}, [
        props['value'],
        button({'onClick': (e) => props['increment']()}, '+')
      ]);
}

class App extends Component {
  @override
  ReactElement render() => connect<State>(
        (state) => {'value': state.count},
        (dispatch) => {'increment': () => dispatch(Increment())},
      )(foo);
}

void main() {
  setClientConfiguration();

  final store = Store<State>(State(0));
  final provider = registerComponent(() => Provider<State>(store: store));

  store.stream.listen(print);

  render(provider({}, app({})), querySelector('#root'));
}

example/main.dart

import 'dart:html' show querySelector;

import 'package:react/react.dart';
import 'package:react/react_client.dart' show setClientConfiguration;
import 'package:react/react_client/react_interop.dart';
import 'package:react/react_dom.dart' show render;
import 'package:react_redurx/react_redurx.dart';
import 'package:redurx/redurx.dart';

final app = registerComponent(() => App());
final foo = registerComponent(() => Foo());

class State {
  State(this.count);
  final int count;

  @override
  String toString() => '{count: $count}';
}

class Increment implements Action<State> {
  State reduce(State state) => State(state.count + 1);
}

class Foo extends Component {
  @override
  ReactElement render() => div({}, [
        props['value'],
        button({'onClick': (e) => props['increment']()}, '+')
      ]);
}

class App extends Component {
  @override
  ReactElement render() => connect<State>(
        (state) => {'value': state.count},
        (dispatch) => {'increment': () => dispatch(Increment())},
      )(foo);
}

void main() {
  setClientConfiguration();

  final store = Store<State>(State(0));
  final provider = registerComponent(() => Provider<State>(store: store));

  store.stream.listen(print);

  render(provider({}, app({})), querySelector('#root'));
}

Use this package as a library

1. Depend on it

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


dependencies:
  react_redurx: ^0.1.0

2. Install it

You can install packages from the command line:

with pub:


$ pub get

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

3. Import it

Now in your Dart code, you can use:


import 'package:react_redurx/react_redurx.dart';
  
Version Uploaded Documentation Archive
0.1.0 Jul 28, 2018 Go to the documentation of react_redurx 0.1.0 Download react_redurx 0.1.0 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
40
Overall:
Weighted score of the above. [more]
38
Learn more about scoring.

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

  • Dart: 2.0.0
  • pana: 0.12.4

Platforms

Detected platforms: web

Primary library: package:react_redurx/react_redurx.dart with components: html, js.

Maintenance issues and suggestions

Maintain CHANGELOG.md. (-20 points)

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

Use constrained dependencies. (-20 points)

The pubspec.yaml contains 1 dependency without version constraints. Specify version ranges for the following dependencies: react.

The description is too short. (-20 points)

Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev <3.0.0
collection ^1.14.11 1.14.11
react 5.0.0-dev.alpha.1
redurx ^0.1.0+1 0.1.0+1 0.3.0+12
Transitive dependencies
js 0.6.1+1
rxdart 0.18.1
Dev dependencies
build_runner ^0.9.2
build_web_compilers ^0.4.1