mirror of
https://github.com/pybricks/pybricks-code.git
synced 2026-09-12 01:23:52 +00:00
rename service worker actions to do/did pattern
This commit is contained in:
@@ -4,8 +4,8 @@
|
||||
import { Action } from 'redux';
|
||||
|
||||
export enum ServiceWorkerActionType {
|
||||
Update = 'serviceWorker.update',
|
||||
Success = 'serviceWorker.success',
|
||||
DidUpdate = 'serviceWorker.didUpdate',
|
||||
DidSucceed = 'serviceWorker.didSucceed',
|
||||
}
|
||||
|
||||
export type ServiceWorkerAction<
|
||||
@@ -14,14 +14,14 @@ export type ServiceWorkerAction<
|
||||
registration: ServiceWorkerRegistration;
|
||||
};
|
||||
|
||||
export function update(
|
||||
export function didUpdate(
|
||||
registration: ServiceWorkerRegistration,
|
||||
): ServiceWorkerAction<ServiceWorkerActionType.Update> {
|
||||
return { type: ServiceWorkerActionType.Update, registration };
|
||||
): ServiceWorkerAction<ServiceWorkerActionType.DidUpdate> {
|
||||
return { type: ServiceWorkerActionType.DidUpdate, registration };
|
||||
}
|
||||
|
||||
export function success(
|
||||
export function didSucceed(
|
||||
registration: ServiceWorkerRegistration,
|
||||
): ServiceWorkerAction<ServiceWorkerActionType.Success> {
|
||||
return { type: ServiceWorkerActionType.Success, registration };
|
||||
): ServiceWorkerAction<ServiceWorkerActionType.DidSucceed> {
|
||||
return { type: ServiceWorkerActionType.DidSucceed, registration };
|
||||
}
|
||||
|
||||
+3
-3
@@ -10,7 +10,7 @@ import { applyMiddleware, createStore } from 'redux';
|
||||
import { createLogger } from 'redux-logger';
|
||||
import createSagaMiddleware from 'redux-saga';
|
||||
import './index.scss';
|
||||
import { success, update } from './actions/service-worker';
|
||||
import { didSucceed, didUpdate } from './actions/service-worker';
|
||||
import App from './components/App';
|
||||
import NotificationStack from './components/NotificationStack';
|
||||
import rootReducer from './reducers';
|
||||
@@ -76,8 +76,8 @@ ReactDOM.render(
|
||||
// unregister() to register() below. Note this comes with some pitfalls.
|
||||
// Learn more about service workers: https://cra.link/PWA
|
||||
serviceWorkerRegistration.register({
|
||||
onUpdate: (r) => store.dispatch(update(r)),
|
||||
onSuccess: (r) => store.dispatch(success(r)),
|
||||
onUpdate: (r) => store.dispatch(didUpdate(r)),
|
||||
onSuccess: (r) => store.dispatch(didSucceed(r)),
|
||||
});
|
||||
|
||||
// If you want to start measuring performance in your app, pass a function
|
||||
|
||||
@@ -147,7 +147,7 @@ const list: Reducer<NotificationList, Action> = (state = [], action) => {
|
||||
];
|
||||
case NotificationActionType.Remove:
|
||||
return state.filter((e) => e.id !== action.id);
|
||||
case ServiceWorkerActionType.Update:
|
||||
case ServiceWorkerActionType.DidUpdate:
|
||||
return append(
|
||||
state,
|
||||
Level.Info,
|
||||
@@ -155,7 +155,7 @@ const list: Reducer<NotificationList, Action> = (state = [], action) => {
|
||||
undefined,
|
||||
'https://github.com/pybricks/pybricks-code/issues/102',
|
||||
);
|
||||
case ServiceWorkerActionType.Success:
|
||||
case ServiceWorkerActionType.DidSucceed:
|
||||
return append(state, Level.Info, MessageId.ServiceWorkerSuccess);
|
||||
default:
|
||||
return state;
|
||||
|
||||
Reference in New Issue
Block a user