|
1 | 1 | /*globals CustomEvent, config*/ |
2 | | -import CoCreateSocket from "@cocreate/socket-client"; |
| 2 | +import socket from "@cocreate/socket-client"; |
3 | 3 | import CoCreateAction from '@cocreate/actions'; |
4 | 4 | import CoCreateRender from '@cocreate/render'; |
5 | 5 | import CoCreateElements from '@cocreate/elements'; |
6 | 6 |
|
7 | | -let socketApi = new CoCreateSocket('api'); |
8 | | - |
9 | 7 | const CoCreateApi = { |
10 | 8 | components: { }, |
11 | | - |
| 9 | + |
12 | 10 | init: function({name, component}) { |
13 | 11 | this.register(name || component.name, component); |
14 | | - if (!socketApi.sockets.size) |
15 | | - socketApi.create(); |
| 12 | + if (!socket.sockets.size) |
| 13 | + socket.create({prefix: 'api'}); |
16 | 14 | }, |
17 | 15 |
|
18 | 16 | register: function(name, component) { |
19 | 17 | const self = this; |
20 | 18 | if (typeof this.components[name] === 'undefined') { |
21 | 19 | this.components[name] = component; |
22 | 20 |
|
23 | | - socketApi.listen(name, (data) => { |
| 21 | + socket.listen(name, (data) => { |
24 | 22 | self.__response(name, data); |
25 | 23 | }); |
26 | 24 |
|
@@ -137,7 +135,7 @@ const CoCreateApi = { |
137 | 135 | }, |
138 | 136 |
|
139 | 137 | send: function(component, action, data) { |
140 | | - socketApi.send(component, {action, data}); |
| 138 | + socket.send(component, {action, data}); |
141 | 139 | }, |
142 | 140 |
|
143 | 141 | render: function(action, data) { |
|
0 commit comments