ストリーム経由でAPIにリクエストできるように

This commit is contained in:
syuilo
2018-04-11 17:40:01 +09:00
parent 91791834be
commit bd3d57a67f
15 changed files with 137 additions and 179 deletions

View File

@ -444,23 +444,28 @@ export default class MiOS extends EventEmitter {
// Append a credential
if (this.isSignedIn) (data as any).i = this.i.token;
// TODO
//const viaStream = localStorage.getItem('enableExperimental') == 'true';
const viaStream = localStorage.getItem('enableExperimental') == 'true';
return new Promise((resolve, reject) => {
/*if (viaStream) {
if (viaStream) {
const stream = this.stream.borrow();
const id = Math.random().toString();
stream.once(`api-res:${id}`, res => {
resolve(res);
if (res.res) {
resolve(res.res);
} else {
reject(res.e);
}
});
stream.send({
type: 'api',
id,
endpoint,
data
});
} else {*/
} else {
const req = {
id: uuid(),
date: new Date(),