https://github.com/mattkrick/relay-linear-publish-queue
Publish changes in the order they're received.
https://github.com/mattkrick/relay-linear-publish-queue
Last synced: about 2 months ago
JSON representation
Publish changes in the order they're received.
- Host: GitHub
- URL: https://github.com/mattkrick/relay-linear-publish-queue
- Owner: mattkrick
- Created: 2019-07-10T21:32:54.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2022-02-12T09:25:24.000Z (over 3 years ago)
- Last Synced: 2025-03-24T05:43:57.224Z (2 months ago)
- Language: TypeScript
- Size: 221 KB
- Stars: 4
- Watchers: 3
- Forks: 0
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# relay-linear-publish-queue
Publish changes in the order they're received
## Installation
`yarn add relay-linear-publish-queue`
## Why
- By default, Relay publishes changes in an arbitrary order, making local and optimistic updates unpredictable based on latency.
- By default, Relay double normalizes every optimistic update & reconstructs the state tree more often than necessary
- For more info, read the blog post: [https://dev.to/mattkrick/distributed-state-101-why-i-forked-facebook-s-relay-1p7d](https://dev.to/mattkrick/distributed-state-101-why-i-forked-facebook-s-relay-1p7d)## High level architecture
- Updates (local, optimistic, or server) get put into a queue
- Updates get processed in that order
- When a server update returns, it's provided the same state as it's optimistic counterpart. This is standard for distributed systems. Otherwise, state is a function of latency, which causes divergence.## Usage
```js
import defaultGetDataID from 'relay-runtime/lib/defaultGetDataID'
import LinearPublishQueue from 'relay-linear-publish-queue'
const publishQueue = new LinearPublishQueue(store, handlerProvider, defaultGetDataID)
new Environment({store, handlerProvider, network, publishQueue})
```Also requires installing my fork. See package.json for the hash
## License
MIT