Skip to content

Commit 427eb80

Browse files
committed
Merged with lite
2 parents f45a5bd + 52e787a commit 427eb80

File tree

188 files changed

+3194
-9463
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

188 files changed

+3194
-9463
lines changed

.eslintrc

Lines changed: 0 additions & 9 deletions
This file was deleted.

.gitignore

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,4 @@
1-
# Dependency directories
2-
node_modules/
3-
4-
# Logs
5-
log
6-
logs
7-
*.log
8-
npm-debug.log*
9-
10-
# IDE
11-
.idea
12-
13-
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
14-
.grunt
15-
16-
# Files
17-
dist
18-
testing/
19-
package-lock.json
20-
yarn.lock
21-
examples/drag/package-lock.json
22-
examples/todomvc/package-lock.json
23-
.vscode/launch.json
24-
*.tgz
1+
dist
2+
node_modules
3+
package-lock.json
4+
test/.test

.npmignore

Lines changed: 0 additions & 26 deletions
This file was deleted.

.prettierrc

Lines changed: 0 additions & 7 deletions
This file was deleted.

.vscode/launch.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"type": "node",
6+
"request": "launch",
7+
"name": "Debug",
8+
"program": "${workspaceFolder}/${relativeFile}"
9+
},
10+
{
11+
"type": "node",
12+
"request": "launch",
13+
"name": "AVA",
14+
"program": "${workspaceFolder}/node_modules/ava/profile.js",
15+
"args": ["${file}"],
16+
"skipFiles": ["<node_internals>/**/*.js"]
17+
},
18+
{
19+
"type": "node",
20+
"request": "launch",
21+
"name": "AVA specific",
22+
"program": "${workspaceFolder}/node_modules/ava/profile.js",
23+
"args": ["test/createNode.js"],
24+
"skipFiles": ["<node_internals>/**/*.js"]
25+
}
26+
]
27+
}

Gruntfile.js

Lines changed: 0 additions & 152 deletions
This file was deleted.

README.md

Lines changed: 39 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,55 @@
1+
<div align="center">
12

2-
<p align="center"><a href="https://distributedobjectprotocol.org"><img width="200"src="https://distributedobjectprotocol.org/img/logo.svg"></a></p>
3+
<p align="center"><a href="https://distributedobjectprotocol.org"><img src="https://distributedobjectprotocol.org/img/logo.svg" width="200"></a></p>
34

4-
<p align="center">
5-
<a href="https://www.npmjs.com/package/dop"><img alt="npm version" src="https://img.shields.io/npm/v/dop.svg"></a>
6-
<a href="https://travis-ci.org/DistributedObjectProtocol/dop"><img alt="Build Status" src="https://api.travis-ci.org/DistributedObjectProtocol/dop.svg?branch=master"></a>
7-
<a href="https://www.npmjs.com/package/dop"><img alt="license" src="https://img.shields.io/npm/l/dop.svg"></a>
8-
<a href="https://spectrum.chat/dop"><img alt="Join the community" src="https://withspectrum.github.io/badge/badge.svg"></a>
9-
</p>
5+
[![npm](https://img.shields.io/npm/v/dop?style=flat-square)](https://www.npmjs.com/package/dop)
6+
[![npm bundle size](https://img.shields.io/bundlephobia/minzip/dop?style=flat-square)](https://bundlephobia.com/result?p=dop)
7+
[![Build Status](https://api.travis-ci.org/DistributedObjectProtocol/dop.svg?branch=master&style=flat-square)](https://travis-ci.org/DistributedObjectProtocol/dop)
8+
![GitHub](https://img.shields.io/github/license/artalar/reatom?style=flat-square)
109

11-
## Distributed Object Protocol is for
10+
<br/>
11+
<a href="https://distributedobjectprotocol.org/guide/javascript">https://distributedobjectprotocol.org/</a>
12+
<br/>
13+
<br/>
1214

13-
**State management**, Remote procedure calls, Reactive programming,
14-
Data sync, Pub/Sub, Optimistic updates, Time-travel debugging, Unidirectional data flow and **Real time apps**.
15+
</div>
1516

16-
This repository is the JavaScript implementation of the protocol that runs on node.js and Browsers.
17+
**Distributed Object Protocol** is a thin layer on top of your data network that helps you communicate server and clients (nodes) using [RPCs](https://en.wikipedia.org/wiki/Remote_procedure_call). It is also a pattern that makes easy update, mutate or even sync the state of your App using [Patches](https://github.com/DistributedObjectProtocol/protocol#Patches).
1718

18-
<!--
19-
## Connecting two nodes
19+
## Quick example using RPCs with WebSockets
2020

2121
```js
22-
// Server (node.js)
23-
const dop = require('dop')
24-
const object = dop.register({
25-
fullname: 'John Doe',
26-
square: number => number * number
22+
// Server
23+
const { createNode } = require('dop')
24+
const WebSocket = require('ws')
25+
const wss = new WebSocket.Server({ port: 8080 })
26+
27+
const sum = (a, b) => a + b
28+
const multiply = (a, b) => a * b
29+
const getCalculator = () => ({ sum, multiply })
30+
31+
wss.on('connection', ws => {
32+
const client = createNode()
33+
client.open(ws.send.bind(ws), getCalculator)
34+
ws.on('message', client.message)
2735
})
28-
dop.listen() // WebSockets on port 4444 (https://github.com/websockets/ws)
29-
dop.onSubscribe(() => object)
3036
```
3137

3238
```js
33-
// Client (browser)
34-
import dop from 'dop'
35-
const server = dop.connect() // Native WebSockets 'ws://localhost:4444'
36-
const objectFromServer = await server.subscribe()
37-
console.log(objectFromServer.fullname) // > "John Doe"
38-
console.log(await objectFromServer.square(5)) // > 25
39-
```-->
40-
41-
42-
43-
44-
45-
Check the website for more detailed information [https://distributedobjectprotocol.org/](https://distributedobjectprotocol.org/)
46-
39+
// Client
40+
const ws = new WebSocket('ws://localhost:8080')
41+
const server = createNode()
42+
ws.on('open', async () => {
43+
const getCalculator = server.open(ws.send.bind(ws))
44+
const { sum, multiply } = await getCalculator()
45+
const result1 = await sum(5, 5)
46+
const result2 = await multiply(3, 3)
47+
console.log(result1, result2) // 10, 9
48+
})
49+
ws.on('message', server.message)
50+
```
4751

52+
Check the website for more info [https://distributedobjectprotocol.org/](https://distributedobjectprotocol.org/guide/javascript)
4853

4954
## License
5055

0 commit comments

Comments
 (0)