JSPM

@fabrix/spool-realtime

1.6.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 15
  • Score
    100M100P100Q66443F
  • License MIT

Spool: Realtime, Synchronize the client and server via WebSockets using Primus

Package Exports

  • @fabrix/spool-realtime

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@fabrix/spool-realtime) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

spool-realtime

📦 Realtime Spool. Synchronize the client and server via WebSockets using Primus

Gitter NPM version Build Status Test Coverage Dependency Status Follow @FabrixApp on Twitter

Getting Started

Install

npm install --save @fabrix/spool-realtime

Configure

Then edit config/main.ts

export const main = {
  spools: [
    require('@fabrix/spool-router').RouterSpool,
    require('@fabrix/spool-express').ExpressSpool, // Or use a different Webserver Spool 
    require('@fabrix/spool-realtime').RealtimeSpool
  ]
}

Configure

Create the config file: config/realtime.ts

export const realtime = {
  prefix: null, // The prefix to use for the primus endpoint
  primus:{
    options:{
      //these options are passed directly to the Primus constructor: https://github.com/primus/primus#getting-started
    }
  },
  plugins: {
    // Plugins are a key and a library passed to primus.use
    redis: require('primus-redis-rooms')
  }
}

Client

You can set the config path for the generated primus.js file by either setting

config.main.paths.www (common defaults for webserver spools) or through config.realtime.path which should likely be to a static directory.

You can include the primus client library as a script:

<script src="/<realtime.path>/primus.js"></script>

License

MIT