npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

redux-service-demo

v1.1.20

Published

A simple React UI for testing Redux-based data services

Downloads

28

Readme

redux-service-demo

A React UI for testing Redux Service components without the need to integrate them into a large application

Build Status

See the demo here: https://dannywieser.github.io/redux-service-demo/

Demo uses the fake todos api available here: http://jsonplaceholder.typicode.com/

Demo also uses the redux-service-utils from here to reduce boilerplate in the async service code: https://github.com/dannywieser/redux-service-util

Overview

A Redux Data Service is a Redux wrapper for an API that maps API functionality to Redux Actions.

Each service will manage/populate a slice of state that can be combined to implement larger applications.

Striving to develop micro-components vs monolithic apps, you might create Redux Data Services that live alongside each micro-service API utilized in your application.

This demo application allows testing of each individual Redux Service in a simple UI that presents a list of services and actions for each. Configuration is used to specify data fields that need to be collected to each action, and then the action dispatch can be tested, either connected to a live API or using a mock api layer.

Usage

Add as a project dependency

yarn install redux-service-demo --dev

Import the necessary functions (and CSS if desired)

  import { configure, renderDemo } from 'redux-service-demo';
  import 'redux-service-demo/styles/index.css';

Configure if you want to use redux logging and the application title

  configure({
    useLogger: true,
    title: 'Redux Service Demo',
  });

Define your services object (see below) and pass it to the renderDemo function, along with the target container element for rendering

renderDemo(services, document.getElementById('container'));

Configure your services as needed and load the application in a browser, then start testing your services!

You can default to a particular service/action by providing parameters in the url:

?service=todos&action=fetchTodoById

You can also set a default value for any field by setting a url parameter with the field name:

&userId=1&title=atitle

Services Object

A Redux Data Service/State would typically consist of:

  • a reducer
  • an enumerated set of types available for the state
  • a map of types to action function implementations

The services object expected by this application uses those properties, with the addition of another property representing an array of parameters expected by each action function (i.e. form fields in the application).

Actions will be triggered with a Redux dispatch, with all form fields being passed as individual parameters to the action function.

The services object itself is a map of individual services (keyname = servicename):

Example:

{
  serviceA: {
    reducer: ...
    types: ...
    actions: ...
    forms: [
      action1: ['field1A'],
      action2: ['field2A']
    ]
  },
  serviceB: {
    reducer: ...
    types: ...
    actions: ...
    forms: [
      actionA: ['fieldA1'],
      actionB: ['fieldB1']
    ]
  },  
}