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

reduxwork

v2.0.8

Published

Framework for creating redux actions and reducers that get data from server via ajax of websockets

Downloads

82

Readme

Reduxwork

Build Status

A small Redux framework for creating actions and reducers that work with AJAX or WebSocket functions and create real-time apps.

For the previous version and installation, instructions, pleas check the [https://github.com/michalkow/reduxwork/tree/v1](v1 branch).

Install

Install from npm:

npm install reduxwork 

You need to have redux and redux-offline

Usage

Actions and reducer configuration options and defaults

const reduxwork = new Reduxwork({
  keyName: 'id',// Name of identificator key in your database.
  addKeyOnCreate: false, // Reducers only. When creating a temporary item (before socket/fetch) random indentificator will be added.
  rewriteOnUpdate: true,
  socketEventName: 'redux_action_event', // Actions only. Name of event that will be send by socket.io.
  socket: null, // Actions only. Socket funtion to use for transport.
  transport: 'fetch',
  virtualFieldsName: 'virtualFields',
  localFieldsName: 'localFields',
  uuidOptions: {},
  uuidVersion: 'v4',
  actionInject: (action) => action,
  validationHook: null,
  createKey: null,
  schemas: {}
});

Use with redux and redux-offline

import { applyMiddleware, createStore, compose } from 'redux';
import { createOffline } from '@redux-offline/redux-offline';
import offlineConfig from '@redux-offline/redux-offline/lib/defaults';
import reduxwork from './reduxwork';
import reducers from './reducers';

const offlineOptions = Object.assign({}, offlineConfig, reduxwork.createOfflineOptions());

const { middleware, enhanceReducer, enhanceStore } = createOffline(offlineOptions);

const store = createStore(
  enhanceReducer(reduxwork.createRootReducer([reducers])),
  reduxwork.createInitialState(),
  compose(enhanceStore, applyMiddleware(middleware))
);

Reducer creators

import reduxwork from './reduxwork';

export default {
	// Standard creator
  messages: reduxwork.createIoReducers('messages'),
  // Creator with added state and actions to handle
  users: reduxwork.createIoReducers('users', {
   	WENT_ONLINE(state, action) {
      return Object.assign({}, state, {
      	online: [...state.online, action.data]
      })        
    },   
   	WENT_OFFLINE(state, action) {
      return Object.assign({}, state, {
      	online: _.reject([...state.online], action.data)
      })        
    }
  })
}

Action creators

import reduxwork from './reduxwork';

export var {
  findMessages,
  createMessages,
  updateMessages,
  destroyMessages,
  clearMessages,
  selectMessages,
  syncMessages,
  receiveMessages,
  resetMessages
} = reduxwork.createIoActions('Messages');

export var {
  findUsers,
  createUsers,
  updateUsers,
  destroyUsers,
  clearUsers,
  selectUsers,
  syncUsers,
  receiveUsers,
  resetUsers
} = reduxwork.createIoActions('Users');

export var wentOffline = reduxwork.createPostAction('WENT_OFFLINE');
export var wentOnline = reduxwork.createPostAction('WENT_ONLINE');

Framework

I created this libary while working on my own projects. It has been really useful, so I thought others might like it as well. It was created to fit me and my own style. Did my best to turn it into an open-source project that accounts for a broad range of usecases. If you have any feedback on style, naming or other things, please let me know or submit a pull request. Thanks!

License

Reduxwork is released under MIT license.

Credits

Reduxwork was created by Michał Kowalkowski. You can contact me at [email protected]