reapop-redux-axios-middleware
v0.5.0
Published
Redux middleware to trigger reapop's notifications from axios actions.
Downloads
3
Readme
reapop-redux-axios-middleware
Redux middleware to trigger reapop's notifications from axios actions.
Overview
This module allows you to dispatch notifications from axios actions using reapop.
Installation
Fist, install redux-axios-middleware and reapop. Then:
npm i -S reapop-redux-axios-middleware
Notifications
export const saveProfile = (userId, profile) => {
return {
types: [SAVE_PROFILE_REQUEST, SAVE_PROFILE_SUCCESS, SAVE_PROFILE_FAILURE],
payload: {
request: {
url: `/users/${userId}`,
method: 'PUT',
data: profile,
},
messages: [{
title: 'Profile',
message: 'The profile was saved!',
status: 'success',
dismissible: true,
dismissAfter: 3000
},
{
title: 'Profile',
message: 'Error saving the profile.',
status: 'error',
dismissible: true,
dismissAfter: 3000
}]
}
};
};