-
Notifications
You must be signed in to change notification settings - Fork 50
/
subscribeAllCardUpdates.js
46 lines (40 loc) · 1.12 KB
/
subscribeAllCardUpdates.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
const { ActionCable } = require('@sorare/actioncable');
const cable = new ActionCable({
headers: {
// 'Authorization': `Bearer <YourJWTorOAuthToken>`,
// 'APIKEY': '<YourOptionalAPIKey>'
}
});
cable.subscribe('anyCardWasUpdated(rarities: [limited, rare, super_rare, unique]) { slug }', {
connected() {
console.log("connected");
},
disconnected(error) {
console.log("disconnected", error);
},
rejected(error) {
console.log("rejected", error);
},
received(data) {
if (data?.result?.errors?.length > 0) {
console.log('error', data?.result?.errors);
return;
}
const anyCardWasUpdated = data?.result?.data?.anyCardWasUpdated;
if (!anyCardWasUpdated) {
return;
}
const { slug } = anyCardWasUpdated;
console.log('a card was updated', slug);
}
});
cable.subscribe('bundledAuctionWasUpdated { id }', {
received(data) {
const bundledAuctionWasUpdated = data?.result?.data?.bundledAuctionWasUpdated;
if (!bundledAuctionWasUpdated) {
return;
}
const { id } = bundledAuctionWasUpdated;
console.log('a bundled auction was updated', id);
}
});