Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ryardley/drator
A simple API for sending data from the server to the client in the context of an isomorphic app.
https://github.com/ryardley/drator
Last synced: 20 days ago
JSON representation
A simple API for sending data from the server to the client in the context of an isomorphic app.
- Host: GitHub
- URL: https://github.com/ryardley/drator
- Owner: ryardley
- Created: 2015-09-13T08:21:34.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2015-09-13T12:17:08.000Z (about 9 years ago)
- Last Synced: 2024-10-16T21:03:51.385Z (29 days ago)
- Language: JavaScript
- Homepage:
- Size: 176 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Drator
Simple API for sending data from the server to the client mainly so I can get used to publishing to npm.
## Usage
### Simple data sharing
The idea is to send structured data on the rendered HTML page to your clientside code without the need for asynchronous API calls. This is done so that your clientside code can pick up the state of the app as constructed by the server and continue to serve user interations.
#### To send a message
```js
// server.js
import {dehydrate} from 'drator';const markup = dehydrate('App', {simple: 'object'});
// 'window.App={"simple":"object"}'
```#### To recieve a message
```js
// client.js
import {hydrate} from 'drator';const data = hydrate('App');
data.simple; // 'object'
```