Web Notification plugin for Choo
npm install choo-notification[Web Notification][notification] plugin for Choo.
_Note: be careful when using notifications. Overuse, or even asking for
permissions unexpectedly can provide people with a bad experience. Make sure
people know why you're asking for permission to send notifications. Use this API
responsibly._
js
var html = require('choo/html')
var choo = require('choo')var app = choo()
app.use(require('choo-devtools')())
app.use(require('./')())
app.route('/', (state, emit) => {
return html
function enable () {
emit('notification:request')
}
function notify () {
if (state.notification.permission) {
emit('notification:new', 'clicky!')
}
}
})
app.mount('body')
`
or
'notification:denied' after calling it. Also emits a 'render' event after
the permission state changes.$3
Emitted after calling 'notification:request'.$3
Emitted after calling 'notification:request'.$3
Emit a new notification. Make sure you have access to send notifications before.API
$3
Create a new choo-notification instance.Installation
`sh
$ npm install choo-notification
``[0]: https://img.shields.io/badge/stability-experimental-orange.svg?style=flat-square
[1]: https://nodejs.org/api/documentation.html#documentation_stability_index
[2]: https://img.shields.io/npm/v/choo-notification.svg?style=flat-square
[3]: https://npmjs.org/package/choo-notification
[4]: https://img.shields.io/travis/choojs/choo-notification/master.svg?style=flat-square
[5]: https://travis-ci.org/choojs/choo-notification
[6]: https://img.shields.io/codecov/c/github/choojs/choo-notification/master.svg?style=flat-square
[7]: https://codecov.io/github/choojs/choo-notification
[8]: http://img.shields.io/npm/dm/choo-notification.svg?style=flat-square
[9]: https://npmjs.org/package/choo-notification
[10]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square
[11]: https://github.com/feross/standard
[notification]: https://developer.mozilla.org/en-US/docs/Web/API/Notifications_API/Using_the_Notifications_API