redux_prism 0.1.2

redux_prism #

Build Status Coverage Status pub package

Library used to easily access dispatched actions in a Redux Store. The library defines a pattern to catch new dispatched actions and listen to them in a reactive context. The StorePrism.middleware works like a proxy in the store middlewares and add every new action in the StorePrism.actions stream.

Usage #

import 'dart:async';

import 'package:flutter/material.dart';
import 'package:flutter_redux/flutter_redux.dart';
import 'package:redux/redux.dart';
import 'package:redux_prism/redux_prism.dart';

void main() => runApp(MessageApp());

class MessageApp extends StatelessWidget {
  Widget build(BuildContext context) =>
    StoreProvider<String>(
      store: Store<String>(
        (state, action) => state,
        middleware: [
          // register StorePrism "proxy" middleware
          StorePrism.middleware
        ]
      ),
      child: MaterialApp(
        title: 'Redux Prism',
        home: MessagePage()
      )
    );
}

@immutable
class MessageAction {
  final String message;

  MessageAction({this.message});

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

class MessagePage extends StatefulWidget {
  _MessagePageState createState() => _MessagePageState();
}

class _MessagePageState extends State<MessagePage> {
  final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
  final TextEditingController _messageController = TextEditingController();
  // used to cancel the subscription, when the widget is disposed
  StreamSubscription _actionsSubscription;

  @override
  void initState() {
    super.initState();
    // listen to the actions stream and show a snackbar when a new action is dispatched
    _actionsSubscription = StorePrism.actions
      .listen((action) {
        _scaffoldKey.currentState
          .showSnackBar(SnackBar(content: Text(action.toString())));
      });
  }

  @override
  void dispose() {
    // ever remember to cancel the listen in widget dispose hook
    _actionsSubscription.cancel();
    super.dispose();
  }

  Widget build(BuildContext context) =>
    Scaffold(
      key: _scaffoldKey,
      appBar: AppBar(title: Text('Redux Prism')),
      body: Column(
        children: <Widget>[
          TextField(
            controller: _messageController,
            decoration: InputDecoration(labelText: 'Message')
          ),
          StoreBuilder<String>(
            builder: (_, store) =>
              OutlineButton(
                onPressed: () =>
                  store.dispatch(MessageAction(message: _messageController.text)),
                child: Text('SEND')
              )
          )
        ]
      )
    );
}

0.1.2 #

Changing to Dart 2 stable version

  • Changing to stable sdk version
  • linking repository tag to every version in CHANGELOG.md

0.1.1 #

Dart 2 compatibility

  • Resolving sdk version

0.1.0 #

Initial version

  • Includes resource to extra power redux with ability to catch actions like a stream
  • Includes StorePrism class to access the actions stream and the injectable middleware responsible for catch and put new actions to the stream

example/README.md

example #

A new Flutter project.

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:
  redux_prism: ^0.1.2

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or 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:redux_prism/redux_prism.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
47
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
73
Learn more about scoring.

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

  • Dart: 2.4.0
  • pana: 0.12.19

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in primary library package:redux_prism/redux_prism.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
Dev dependencies
test ^1.6.1

Admin