react_redurx 0.1.0

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';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
0
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
0
Overall:
Weighted score of the above. [more]
0
Learn more about scoring.

We analyzed this package on Jun 5, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.2
  • pana: 0.13.8-dev

Analysis issues and suggestions

Fix dependencies in pubspec.yaml.

Running pub upgrade failed with the following output:

ERR: Git error. Command: `git clone --mirror git://github.com/leocavalcante/react-dart.git /tmp/pub-cache-dirSUSNZY/git/cache/react-dart-bd3fbc81b9e03afe6934f14be84c07028b2e19a1`
 stdout: 
 stderr: Cloning into bare repository '/tmp/pub-cache-dirSUSNZY/git/cache/react-dart-bd3fbc81b9e03afe6934f14be84c07028b2e19a1'...
 fatal: remote error: 
   Repository not found.
 exit code: 128

Maintenance issues and suggestions

No valid SDK. (-20 points)

The analysis could not detect a valid SDK that can use this package.

Make sure dartdoc successfully runs on your package's source files. (-10 points)

Dependencies were not resolved.

Prefer published dependencies. (-100 points)

The source code in a git repository is mutable and could disappear.

Provide a file named CHANGELOG.md. (-20 points)

Changelog entries help developers follow the progress of your package. See the example generated by stagehand.

Package is getting outdated. (-85.75 points)

The package was last published 96 weeks ago.

The package description is too short. (-20 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev <3.0.0