Join chat

Logux

Logux and WebSocket client/server framework to make:

Ask your questions at community chat or commercial support.

Client Example

  • Using Logux Redux:

    export const Counter = () => {
      const counter = useSelector(state => state.counter)
      const dispatch = useDispatch()
      // Load current counter from server and subscribe to counter changes
      const isSubscribing = useSubscription(['counter'])
      if (isSubscribing) {
        return <Loader></Loader>
      } else {
        // dispatch.sync() will send Redux action to all clients
        return <div>
          <h1>{ counter }</h1>
          <button onClick={ dispatch.sync({ type: 'INC' }) }></button>
        </div>
      }
    }

    Server Example

  • Using Logux Server:

    server.channel('counter', {
      access () {
        // Access control is mandatory
        return true
      },
      async load (ctx) {
        // Load initial state when client subscribing to the channel.
        // You can use any database.
        let value = await db.get('counter')
        return { type: 'INC', value }
      }
    })
    
    server.type('INC', {
      access () {
        return true
      },
      resend () {
        return { channel: 'counter' }
      },
      async process () {
        // Don’t forget to keep action atomic
        await db.set('counter', 'value += 1')
      }
    })

    Talks

    CRDT ideas in Logux

    CRDT ideas in Logux talk

    Using Logux in Production

    Using Logux in Production talk