Installation

Use npm or yarn to install Raid

npm i -S raid
yarn add raid

To use raid you’ll need something that can use commonJS modules, the following code imports the Raid module and creates a new state instance.

// index.js
var Raid = require('raid')

var signal = new Raid.Signal()

The following steps compile this for the browser using browserify, although there are other packagers

browserify index.js > bundle.js

The rest of the code examples will use ES2015 modules and so (currently) require transpilation using something like babel.

Example Babel setup

None of this is strictly necessary, once you have a version of Raid (whether that be via a module system or as a browser global) use whatever you prefer to write your own code, Raid doesn’t care.

A good starting point would be to use the ES2015 preset and the object-rest-spread plugin also fits quite well.

Make sure to add a preset for your rendering engine syntax, if it differs from JS, the examples here expect React so the React preset is required which can handle our JSX. The view layer used with Raid is agnostic, the examples in the repository use InfernoJS as a rendering layer.

Adding the following to your package.json would set up babel and browserify to do their thing, but there are a number of different transformers and bundlers that would equally do a good job:

"scripts": {
  "build": "browserify index.js > bundle.js"
},
"browserify": {
  "transform": [
    "babelify"
  ]
},
"babel": {
  "presets": [
    "es2015",
    "react"
  ],
  "plugins": [
    "transform-object-rest-spread"
  ]
}

Install the following and you should be ready to start firing any code examples into a browser:

npm i -S raid react react-dom
npm i -D browserify babelify babel-preset-es2015 babel-preset-react babel-plugin-transform-object-rest-spread

npm run build

results matching ""

    No results matching ""