Skip to content
Redux compatible API for Logux
JavaScript
Branch: master
Clone or download
Latest commit ff3821f Dec 22, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github/workflows
test
.editorconfig
.gitignore
.npmignore
.travis.yml
CHANGELOG.md
LICENSE
README.md
create-logux-creator.js
index.js
package.json
subscribe.js
use-subscription.js
yarn.lock

README.md

Logux Redux

Logux is a new way to connect client and server. Instead of sending HTTP requests (e.g., AJAX and GraphQL) it synchronizes log of operations between client, server, and other clients.

Documentation: logux.io

This repository contains Redux compatible API on top of Logux Client.

Sponsored by Evil Martians

Install

npm install @logux/redux

Usage

See documentation for Logux API.

import createLoguxCreator from '@logux/redux/create-logux-creator'

import log from '@logux/client/log'

let userId = document.querySelector('meta[name=user]').content
let userToken = document.querySelector('meta[name=token]').content

const createStore = createLoguxCreator({
  credentials: userToken,
  subprotocol: '1.0.0',
  server: 'wss://example.com:1337',
  userId: userToken
})

const store = createStore(reducers, preloadedState)
log(store.client)

export default store
import { Provider } from 'react-redux'
import ReactDOM from 'react-dom'

import store from './store'
import App from './App'

ReactDOM.render(
  <Provider store={store}><App /></Provider>,
  document.getElementById('root')
)
import useSubscription from '@logux/redux/use-subscription'

export const User = ({ id, name }) => {
  const isSubscribing = useSubscription([`user/${ id }`])
  if (isSubscribing) {
    return <Loader />
  } else {
    return <h1>{ name }</h1>
  }
}
You can’t perform that action at this time.