# redux-sw-middleware

> Redux middleware to react to service worker events in redux

Latest version **0.1.0** (published 2016-12-27) · MIT license · 0 weekly downloads

## Install

```sh
npm install redux-sw-middleware
pnpm add redux-sw-middleware
yarn add redux-sw-middleware
bun add redux-sw-middleware
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2016-12-27 |
| First published | 2016-12-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Christoph Kraemer |
| Maintainers | cevou |
| Keywords | redux, middleware, service, worker |

## Links

- npm: https://www.npmjs.com/package/redux-sw-middleware
- Repository: https://github.com/cevou/redux-sw-middleware
- Homepage: https://github.com/cevou/redux-sw-middleware#readme
- Issues: https://github.com/cevou/redux-sw-middleware/issues
- npm.io page: https://npm.io/package/redux-sw-middleware

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 0.1.0 (latest) — 2016-12-27

## README

# Redux Service Worker Middleware

[![npm](https://img.shields.io/npm/v/redux-sw-middleware.svg?style=flat-square)](https://www.npmjs.com/package/redux-sw-middleware)

This middleware registers a service worker for your application and enables Redux 
to receive actions based on events of the service worker.

## Install

```javascript
npm install --save redux-sw-middleware
```

# Example

First add the middleware to redux. You need to pass the path to the service worker file
as a parameter.

```javascript
import createServiceWorkerMiddleware from 'redux-service-worker-middleware'

const serviceWorkerMiddleware = createServiceWorkerMiddleware('/service-worker.js')
const store = createStore(
    reducer,
    initialState,
    applyMiddleware(serviceWorkerMiddleware)
)
```

The middleware will register the service worker and dispatch actions based on state changes
of the service worker.

## Actions

`SERVICE_WORKER_AVAILABLE`: The service worker has downloaded all files is up and running

```javascript
{
    type: 'SERVICE_WORKER_AVAILABLE'
}
```

`SERVICE_WORKER_NEW_CONTENT`: New content is available and will be loaded on the next page reload

```javascript
{
    type: 'SERVICE_WORKER_NEW_CONTENT'
}
```

`SERVICE_WORKER_REDUNDANT`: The service worker became redundant

```javascript
{
    type: 'SERVICE_WORKER_REDUNDANT'
}
```

`SERVICE_WORKER_ERROR`: An error occured

```javascript
{
    type: 'SERVICE_WORKER_ERROR',
    payload: <exception>
}
```

## License

MIT

---
_Source: https://npm.io/package/redux-sw-middleware · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
