Skip to content

Commit aa46f13

Browse files
committed
Merge branch 'release/0.8.0'
2 parents 3a05397 + 6a51e77 commit aa46f13

File tree

7 files changed

+382
-628
lines changed

7 files changed

+382
-628
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## Version 0.8.0 (2016-10-27)
2+
3+
- BREAKING: use promises instead of callbacks
4+
- chore: make (un)watch API coherent with Python API
5+
16
## Version 0.7.0 (2016-10-07)
27

38
- feat: options.returns_count

README.md

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,27 +18,36 @@
1818

1919
```javascript
2020
var client = new Camomile('http://camomile.fr/api');
21-
client.login('username', 'password', callback);
22-
client.logout(callback);
21+
client.login('username', 'password');
22+
client.logout();
2323

24-
client.getCorpora(callback);
24+
client.getCorpora();
2525
client.createCorpus(...);
2626

2727
```
2828

2929
### Server Sent Event
3030

31-
```javascript
31+
See [listen.js](examples/listen.js)
3232

33-
client.listen(function(err, channel_id, eventSource) {
34-
var cancelWatcher = eventSource.watchCorpus(<corpus_id>, function(error, datas) {
35-
console.log(error, data);
36-
});
37-
38-
// For unwatch Corpus :
39-
cancelWatcher();
40-
});
41-
33+
```javascript
34+
var listener=function(error, data) {
35+
console.log(error, data);
36+
};
37+
38+
var client=new Camomile('http://camomile.fr/api');
39+
client
40+
.login('username', 'password')
41+
.then(result =>  {
42+
console.log(result);
43+
return client.watchCorpus(corpusId, listener);
44+
})
45+
.then(() => {
46+
// To unwatch the corpus :
47+
48+
//client.unwatchCorpus(corpusId, listener);
49+
})
50+
.catch(err => console.log(err));
4251
```
4352

4453
## Documentation

camomile.js

Lines changed: 34 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example.js

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,11 @@ var user=process.argv[3];
1515
var password=process.argv[4];
1616

1717
var client=new Camomile(host);
18-
client.login(user, password, function(err,result) {
19-
if(err) {
20-
console.log(err);
21-
return;
22-
}
23-
console.log(result);
24-
25-
client.me(function(err,data) {
26-
if(err) {
27-
console.log(err);
28-
return;
29-
}
30-
console.log(data)
31-
});
32-
});
18+
client
19+
.login(user, password)
20+
.then(result =>  {
21+
console.log(result);
22+
return client.me();
23+
})
24+
.then(result => console.log(result))
25+
.catch(err => console.log(err));

examples/listen.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* An example showing the sse channel listen functionality
3+
*/
4+
5+
var Camomile = require('..');
6+
7+
if(process.argv.length !=6) {
8+
console.log("Usage : node example.js <host> <user> <password> <corpus_id>");
9+
process.exit(1);
10+
}
11+
12+
var host=process.argv[2];
13+
var user=process.argv[3];
14+
var password=process.argv[4];
15+
var corpusId=process.argv[5];
16+
17+
var listener=function(error, data) {
18+
console.log(error, data);
19+
};
20+
21+
var client=new Camomile(host);
22+
client
23+
.login(user, password)
24+
.then(result =>  {
25+
console.log(result);
26+
return client.watchCorpus(corpusId, listener);
27+
})
28+
.then(() => {
29+
// To unwatch the corpus :
30+
31+
//client.unwatchCorpus(corpusId, listener);
32+
})
33+
.catch(err => console.log(err));

0 commit comments

Comments
 (0)