@graffy/client
Advanced tools
Comparing version 0.14.0 to 0.14.1-alpha1
20
index.js
@@ -8,2 +8,4 @@ "use strict"; | ||
var _stringify = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/json/stringify")); | ||
var _common = require("@graffy/common"); | ||
@@ -33,5 +35,8 @@ | ||
source.onerror = function (e) { | ||
end(e); | ||
end(Error('client.sse.transport: ' + e.message)); | ||
}; | ||
source.addEventListener('graffyerror', function (e) { | ||
end(Error('server:' + e.data)); | ||
}); | ||
return function () { | ||
@@ -42,2 +47,15 @@ source.close(); | ||
}); | ||
store.on('write', function (change) { | ||
if (!fetch) throw Error('client.fetch.unavailable'); | ||
console.log('Making post'); | ||
return fetch(baseUrl, { | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/json' | ||
}, | ||
body: (0, _stringify["default"])(change) | ||
}).then(function (res) { | ||
return res.json(); | ||
}); | ||
}); | ||
}; | ||
@@ -44,0 +62,0 @@ } |
@@ -5,3 +5,3 @@ { | ||
"author": "aravind (https://github.com/aravindet)", | ||
"version": "0.14.0", | ||
"version": "0.14.1-alpha1", | ||
"main": "index.js", | ||
@@ -17,5 +17,5 @@ "source": "src/index.js", | ||
"@babel/runtime-corejs3": "^7.8.4", | ||
"@graffy/common": "0.14.0", | ||
"@graffy/stream": "0.14.0" | ||
"@graffy/common": "0.14.1-alpha1", | ||
"@graffy/stream": "0.14.1-alpha1" | ||
} | ||
} |
@@ -23,5 +23,9 @@ import { encodeUrl } from '@graffy/common'; | ||
source.onerror = e => { | ||
end(e); | ||
end(Error('client.sse.transport: ' + e.message)); | ||
}; | ||
source.addEventListener('graffyerror', e => { | ||
end(Error('server:' + e.data)); | ||
}); | ||
return () => { | ||
@@ -32,3 +36,13 @@ source.close(); | ||
}); | ||
store.on('write', change => { | ||
if (!fetch) throw Error('client.fetch.unavailable'); | ||
console.log('Making post'); | ||
return fetch(baseUrl, { | ||
method: 'POST', | ||
headers: { 'Content-Type': 'application/json' }, | ||
body: JSON.stringify(change), | ||
}).then(res => res.json()); | ||
}); | ||
}; | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4156
90
8
+ Added@graffy/common@0.14.1-alpha1(transitive)
+ Added@graffy/stream@0.14.1-alpha1(transitive)
- Removed@graffy/common@0.14.0(transitive)
- Removed@graffy/stream@0.14.0(transitive)
Updated@graffy/common@0.14.1-alpha1
Updated@graffy/stream@0.14.1-alpha1