Giter Club home page Giter Club logo

reactotron-core-server's Introduction

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()

reactotron-core-server's People

Contributors

renovate[bot] avatar rmevans9 avatar alexjebens avatar gantman avatar thibmaek avatar mikhail-rush avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.