https://github.com/cyclejs/cycle-notification-driver
https://github.com/cyclejs/cycle-notification-driver
Last synced: 8 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/cyclejs/cycle-notification-driver
- Owner: cyclejs
- License: mit
- Created: 2015-07-20T12:40:59.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2016-03-31T20:08:09.000Z (over 9 years ago)
- Last Synced: 2024-10-30T00:55:12.838Z (about 1 year ago)
- Language: JavaScript
- Size: 479 KB
- Stars: 22
- Watchers: 11
- Forks: 6
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-cyclejs - cyclejs/cycle-notification-driver ★20 - A Cycle.js Driver for showing and responding to HTML5 Notifications. (Libraries / Drivers)
README
# Cycle Notification Driver
A [Cycle.js](http://cycle.js.org) [Driver](http://cycle.js.org/drivers.html) for showing and responding to HTML5 Notifications.
```
npm install @cycle/notification
```
## Usage
Basics:
```js
import Cycle from '@cycle/core';
import { makeNotificationDriver } from '@cycle/notification'
function main({notification}) {
// ...
}
const drivers = {
notification: makeNotificationDriver()
}
Cycle.run(main, drivers)
```
Simple and normal use case:
```js
function main({notification}) {
let notifications$ = Rx.Observable
.interval(10000)
.startWith(-1)
.map( (value) => ({
title: 'Test Notification',
body: `Interval ${value}`,
tag: 'test-notification',
icon: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAIAAAACDbGyAAAAEUlEQVQIW2Pg3uSLjBgo5AMACSoZ+1zqJ8AAAAAASUVORK5CYII='
}) )
.take(10),
show$ = notification.get('show'),
click$ = notification.get('click'),
error$ = notification.get('error'),
close$ = notification.get('close'),
all$ = Rx.Observable.merge(show$, click$, error$, close$)
all$.do(args => console.log(args)).subscribe()
return {
notification: notifications$
}
}
```