Skip to content

A plugin for Fluxible applications to provide an interface for attaching middlewares

License

Notifications You must be signed in to change notification settings

geekyme/fluxible-plugin-middleware

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Middleware Plugin for Fluxible

A plugin for Fluxible applications to provide an interface that attaches middlewares between an action dispatch and a store handler. Highly inspired by Redux middlewares.

Install

npm install fluxible-plugin-middleware

Usage

import middlewarePlugin from "fluxible-plugin-middleware";
import Fluxible from "fluxible";

const app = new Fluxible();

const logMiddleware = function(actionContext){
    return function(next) {
      return function(type, payload){
        console.log(actionContext);
        console.info(type, payload);
        next(type, payload);
      };
    };
};

app.plug(middlewarePlugin(logMiddleware));

Now, when calling the context.dispatch method within action creators, all action objects will pass through the middlewares before getting dispatched into the stores for handling.

Your middlewares will also have access to the entire actionContext so you can fire the context functions within your middlewares if you like.

For additional middlewares:

app.plug(middlewarePlugin(logMiddleware, secondMiddleware, thirdMiddleware));

About

A plugin for Fluxible applications to provide an interface for attaching middlewares

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published