Have opinions about JavaScript? We want to hear them. Take the 2018 JavaScript Ecosystem Survey »

apeman-service-eventsource

2.0.0 • Public • Published

apeman-service-eventsource

Build Status npm Version JS Standard

Apeman service for SSE event source

Installation

$ npm install apeman-service-eventsource --save

Usage

#!/usr/bin/env node
 
'use strict'
 
const { ApEventsourceService } = require('apeman-service-eventsource')
const { createStore } = require('redux')
const { reducer } = require('apeman-service-base')
const co = require('co')
 
co(function * () {
  let store = createStore(reducer)
  let { observe } = new ApEventsourceService(store)
 
  let server = observe('/sse/system', {}, {
    'server:restart': (e) => { /* ... */ }
  })
 
  /* ... */
 
  server.close()
 
}).catch((err) => console.error(err))
 

API

apeman-service-eventsource@1.0.2

Apeman service for SSE event source

Functions

create(args) -> ApEventsourceService

Create the service instance

Param Type Description
args *

ApEventsourceService Class

Service

new ApEventsourceService(store, options)

Constructor of ApEventsourceService class

Param Type Description
store Object Redux store
options Object Optional settings

service.observe(url, params, handlers) -> EventSource

Observe event source

Param Type Description
url string
params Object
handlers Object Event handlers

License

This software is released under the MIT License.

Links

install

npm i apeman-service-eventsource

Downloadsweekly downloads

6

version

2.0.0

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability