Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/logux/redux
Redux compatible API for Logux
https://github.com/logux/redux
logux redux
Last synced: 1 day ago
JSON representation
Redux compatible API for Logux
- Host: GitHub
- URL: https://github.com/logux/redux
- Owner: logux
- License: mit
- Created: 2017-03-22T14:03:09.000Z (almost 8 years ago)
- Default Branch: main
- Last Pushed: 2024-08-06T00:04:43.000Z (5 months ago)
- Last Synced: 2024-12-17T22:08:00.262Z (8 days ago)
- Topics: logux, redux
- Language: TypeScript
- Homepage: https://logux.org/
- Size: 2.09 MB
- Stars: 127
- Watchers: 9
- Forks: 16
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# 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.* **[Guide, recipes, and API](https://logux.org/)**
* **[Issues](https://github.com/logux/logux/issues)**
and **[roadmap](https://github.com/orgs/logux/projects/1)**
* **[Projects](https://logux.org/guide/architecture/parts/)**
inside Logux ecosystemThis repository contains Redux compatible API on top of [Logux Client].
[Logux Client]: https://github.com/logux/client
## Install
```sh
npm install @logux/core @logux/client @logux/redux redux
```## Usage
See [documentation] for Logux API.
```js
import { CrossTabClient, log } from '@logux/client'
import { createStoreCreator } from '@logux/redux'let userId = document.querySelector('meta[name=user]').content
let token = document.querySelector('meta[name=token]').contentconst client = new CrossTabClient({
subprotocol: '1.0.0',
server: 'wss://example.com:1337',
userId,
token
})const createStore = createStoreCreator(client)
const store = createStore(reducers, preloadedState)
log(store.client)export default store
``````js
import { Provider } from 'react-redux'
import ReactDOM from 'react-dom'import store from './store'
import App from './App'ReactDOM.render(
,
document.getElementById('root')
)
``````js
import { useSubscription } from '@logux/redux'export const User = ({ id, name }) => {
const isSubscribing = useSubscription([`user/${ id }`])
if (isSubscribing) {
return
} else {
return{ name }
}
}
```[documentation]: https://logux.org