@expandorg/app-utils
Advanced tools
Comparing version 0.0.27 to 0.0.28
12
app.js
@@ -13,3 +13,10 @@ // @flow | ||
import { refreshSaga, initSaga, userUpdatedSaga } from './src/app/sagas'; | ||
import { | ||
refreshSaga, | ||
initSaga, | ||
userUpdatedSaga, | ||
addNotification, | ||
clearNotification, | ||
handldNotificationAdded, | ||
} from './src/app/sagas'; | ||
@@ -27,2 +34,5 @@ export { | ||
notificationReducer, | ||
addNotification, | ||
clearNotification, | ||
handldNotificationAdded, | ||
}; |
{ | ||
"name": "@expandorg/app-utils", | ||
"version": "0.0.27", | ||
"version": "0.0.28", | ||
"description": "App utils", | ||
@@ -21,3 +21,3 @@ "main": "index.js", | ||
}, | ||
"gitHead": "72bc54067b852f437c34a1cc8847c3003580f44f" | ||
"gitHead": "55182d5b70d01f5904f886c8df903acaf1fbfb6c" | ||
} |
@@ -0,1 +1,7 @@ | ||
// @flow | ||
import { call, put, take, race } from 'redux-saga/effects'; | ||
import { delay } from '@expandorg/utils'; | ||
import { appActionTypes, userActionTypes } from './actionTypes'; | ||
@@ -17,1 +23,25 @@ | ||
}); | ||
const NOTIFICATION_TIMEOUT = 3000; | ||
declare type NotificationType = 'error' | 'success' | 'warning' | 'message'; | ||
export const addNotification = (type: NotificationType, message: string) => ({ | ||
type: appActionTypes.NOTIFICATION_ADD, | ||
payload: { type, message }, | ||
}); | ||
export const clearNotification = () => ({ | ||
type: appActionTypes.NOTIFICATION_REMOVE, | ||
payload: null, | ||
}); | ||
export function* handldNotificationAdded() { | ||
const { timeout } = yield race({ | ||
timeout: call(delay, NOTIFICATION_TIMEOUT), | ||
clear: take(appActionTypes.NOTIFICATION_REMOVE), | ||
}); | ||
if (timeout) { | ||
yield put(clearNotification()); | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
15744
555