Skip to content
The core reactotron server used by the reactotron app
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.circleci
src
test Initial Commit Dec 4, 2018
.babelrc feat: Update build process Feb 25, 2019
.gitignore feat: Update build process Feb 25, 2019
.prettierignore Initial Commit Dec 4, 2018
.prettierrc
LICENSE Initial Commit Dec 4, 2018
README.md Initial Commit Dec 4, 2018
package.json chore(deps): update dependency semantic-release to v16.0.0-beta.22 (#74) Jul 12, 2019
renovate.json chore: Configure Renovate Apr 16, 2019
rollup.config.js
tsconfig.json
yarn.lock

README.md

reactotron-core-server

This provides the core functionality of the servers allowing it talk to talk to the client.

It is used by reactotron-app and reactotron-cli.

Usage

import { createServer } from 'reactotron-core-server'

// configure a server
const server = createServer({
  port: 9090, // default

  onStart: () => null, // fires when we start the server
  onStop: () => null, // fires when we stop the server
  onConnect: ({ id, address }) => null, // fires when a client connects
  onDisconnect: ({ id, address }) => null, // fires when a client disconnects

  // a handler that fires whenever a message is received
  onCommand: ({type, payload, messageId, date}) => {
    switch (type) {
      case 'hello.client':
        break
      case 'log':
        break
      case 'state.action.complete':
        break
      case 'state.values.response':
        break
      case 'state.keys.response':
        break
      case 'state.values.change':
        break
      case 'api.response':
        break
      case 'bench.report':
        break
    }
  }
})

// start the server
server.start()

// say hello when we connect (this is automatic, you don't send this)
server.send('hello.server', {})

// request some values from state
server.send('state.values.request', { path: 'user.givenName' })

// request some keys from state
server.send('state.keys.request', { path: 'user' })

// subscribe to some state paths so when then change, we get notified
server.send('state.values.subscribe', { paths: ['user.givenName', 'user'] })

// stop the server
server.stop()
You can’t perform that action at this time.