Skip to content
This repository was archived by the owner on Dec 11, 2022. It is now read-only.

Commit caaaae5

Browse files
committed
Update readme.
1 parent 8aeaa5f commit caaaae5

File tree

2 files changed

+10
-35
lines changed

2 files changed

+10
-35
lines changed

README.md

Lines changed: 7 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,10 @@
22

33
[![Latest Stable Version](https://img.shields.io/npm/v/nymph-client-node.svg)](https://www.npmjs.com/package/nymph-client-node) [![Open Issues](https://img.shields.io/github/issues/sciactive/nymph-client-node.svg)](https://github.com/sciactive/nymph-client-node/issues) [![License](https://img.shields.io/github/license/sciactive/nymph-client-node.svg)]()
44

5-
Nymph is an object data store that is easy to use in JavaScript and PHP.
5+
Nymph is an object data store for JavaScript and PHP.
66

77
## Installation
88

9-
You can install Nymph Node Client with NPM.
10-
119
```sh
1210
npm install --save nymph-client-node
1311
```
@@ -18,51 +16,28 @@ The Nymph client requires some browser globals that Node doesn't provide, so thi
1816

1917
It also sets up Nymph.init to also call PubSub.init with your configs, so you don't need to set up PubSub yourself.
2018

21-
## Setting up Nymph in Node.js
19+
## Usage
2220

23-
<div dir="rtl">Quick Setup with NPM</div>
24-
25-
```sh
26-
npm install --save nymph-client-node
27-
```
28-
29-
To use, require it as the Nymph object:
21+
To use, require it instead of `nymph-client`:
3022

3123
```js
32-
const Nymph = require('nymph-client-node').Nymph;
24+
const { Nymph } = require('nymph-client-node');
3325
```
3426

35-
Or, if you need cookie support (like if you're using Tilmeld):
27+
Or, if you need cookie support (like, if you're using [Tilmeld](http://tilmeld.org/)):
3628

3729
```js
3830
const NymphNode = require('nymph-client-node');
3931
NymphNode.enableCookies();
40-
const Nymph = NymphNode.Nymph;
32+
const { Nymph } = NymphNode;
4133
```
4234

4335
Then provide the options to Nymph.init:
4436

4537
```js
4638
Nymph.init({
4739
restURL: 'https://yournymphrestserver/path/to/your/rest.php',
48-
pubsubURL: 'wss://yournymphpubsubserver:8080'
49-
});
50-
```
51-
52-
Now include your entity classes, such as `Todo`, and you can write queries and subscribe to them:
53-
54-
```js
55-
Nymph.getEntities({'class': Todo.class}, {'type': '&', 'strict': ['name', 'Foobar']}).subscribe((todos) => {
56-
console.log("\nNew Foobar Todo Updates: ", todos);
57-
});
58-
59-
const myTodo = new Todo();
60-
myTodo.set({
61-
name: "Foobar",
62-
done: false
63-
});
64-
myTodo.save().then(() => {
65-
alert("You've got new todos!");
40+
pubsubURL: 'wss://yournymphpubsubserver'
6641
});
6742
```
6843

index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ const enableCookies = () => {
1313
};
1414

1515
const NymphClient = require('nymph-client');
16-
const {Nymph, PubSub} = NymphClient;
16+
const { Nymph, PubSub } = NymphClient;
1717

1818
// Make a shortcut for PubSub init.
1919
const _init = Nymph.init;
20-
Nymph.init = (nymphOptions) => {
20+
Nymph.init = nymphOptions => {
2121
_init.call(Nymph, nymphOptions);
2222
if (nymphOptions.pubsubURL) {
2323
PubSub.init(nymphOptions);
2424
}
2525
};
2626

27-
module.exports = {Nymph, PubSub, enableCookies, ...NymphClient};
27+
module.exports = { Nymph, PubSub, enableCookies, ...NymphClient };

0 commit comments

Comments
 (0)