mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 10:45:47 +00:00
feature(config) add sync via sockets
This commit is contained in:
parent
8c6cbcf860
commit
3c9c97560f
3 changed files with 17 additions and 8 deletions
|
|
@ -73,6 +73,10 @@ var CloudCmd, Util, DOM, io;
|
|||
Config.save = save;
|
||||
});
|
||||
|
||||
socket.on('config', function(config) {
|
||||
DOM.Files.set('config', config);
|
||||
});
|
||||
|
||||
socket.on('message', function(data) {
|
||||
onSave(data);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -138,17 +138,20 @@
|
|||
}
|
||||
|
||||
function getConfig(callback) {
|
||||
var promise,
|
||||
RESTful = DOM.RESTful;
|
||||
var RESTful = DOM.RESTful;
|
||||
|
||||
promise = new Promise(function(resolve) {
|
||||
RESTful.Config.read(resolve);
|
||||
});
|
||||
if (!Promises.config)
|
||||
Promises.config = new Promise(function(resolve) {
|
||||
RESTful.Config.read(resolve);
|
||||
});
|
||||
|
||||
promise.then(function(data) {
|
||||
setConfig(data);
|
||||
Promises.config.then(function(data) {
|
||||
if (!Data.config) {
|
||||
Data.config = data;
|
||||
setConfig(data);
|
||||
}
|
||||
|
||||
callback(null, data);
|
||||
callback(null, Data.config);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -77,6 +77,8 @@
|
|||
|
||||
sock.of('/config')
|
||||
.on('connection', function(socket) {
|
||||
socket.emit('config', config);
|
||||
|
||||
socket.on('message', function(json) {
|
||||
var data,
|
||||
is = Util.type.object(json);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue