How to use the @hapi/nes/lib/client.Client function in @hapi/nes

To help you get started, we’ve selected a few @hapi/nes examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github brightleaf / react-hooks / src / use-nes.js View on Github external
const useNes = (url = 'ws://localhost:4567', subscribe) => {
  const [state, dispatch] = useReducer(reducer, {
    messages: [],
    error: null,
    connecting: true,
    connected: false,
  })
  var client = new Nes.Client(url)

  useEffect(() => {
    const connectClient = async () => {
      dispatch({ type: 'connecting', payload: {} })
      return new Promise(async resolve => {
        client.onConnect = () => {
          dispatch({ type: 'connected' })
          return resolve()
        }
        client.onDisconnect = () => {
          dispatch({ type: 'disconnected' })
          return resolve()
        }
        await client.connect()

        client.onUpdate = update => {

@hapi/nes

WebSocket adapter plugin for hapi routes

BSD-3-Clause
Latest version published 3 months ago

Package Health Score

85 / 100
Full package analysis