Ui 2 pubsub components (#6152)
* Remove Application.orig from merge * Disable i18n extraction for development * Retrieve blockNumber via pubsub * Chain via pubsub * StatusIndicator with health * WIP * WIP * s/BlockStatus/BlockNumber/ * Adjust BlockNumber display * Cleanup debug * Fix statusbar indicator * NetPeers component * Add BlockTimestamp * Export statics on observer * Cleanup debug logs * Update references
This commit is contained in:
@@ -17,8 +17,8 @@
|
||||
import EventEmitter from 'eventemitter3';
|
||||
|
||||
import Contract from './contract';
|
||||
import { PromiseProvider, Http as HttpProvider, PostMessage as PostMessageProvider, Ws as WsProvider } from './provider';
|
||||
import { Http as HttpTransport, Ws as WsTransport } from './transport';
|
||||
import { PromiseProvider, Http as HttpProvider, PostMessage as PostMessageProvider, Ws as WsProvider, WsSecure as WsSecureProvider } from './provider';
|
||||
import { Http as HttpTransport, Ws as WsTransport, WsSecure as WsSecureTransport } from './transport';
|
||||
|
||||
import { Db, Eth, Parity, Net, Personal, Shell, Shh, Signer, Trace, Web3 } from './rpc';
|
||||
import Subscriptions from './subscriptions';
|
||||
@@ -74,10 +74,17 @@ export default class Api extends EventEmitter {
|
||||
}
|
||||
}
|
||||
|
||||
get isConnected () {
|
||||
const isConnected = this.provider.isConnected;
|
||||
|
||||
return isConnected || typeof isConnected === 'undefined';
|
||||
}
|
||||
|
||||
get pubsub () {
|
||||
if (!this._pubsub) {
|
||||
throw Error('Pubsub is only available with a subscribing-supported transport injected!');
|
||||
}
|
||||
|
||||
return this._pubsub;
|
||||
}
|
||||
|
||||
@@ -186,12 +193,14 @@ export default class Api extends EventEmitter {
|
||||
static Provider = {
|
||||
Http: HttpProvider,
|
||||
PostMessage: PostMessageProvider,
|
||||
Ws: WsProvider
|
||||
Ws: WsProvider,
|
||||
WsSecure: WsSecureProvider
|
||||
}
|
||||
|
||||
// NOTE: kept for backwards compatibility
|
||||
static Transport = {
|
||||
Http: HttpTransport,
|
||||
Ws: WsTransport
|
||||
Ws: WsTransport,
|
||||
WsSecure: WsSecureTransport
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,8 +14,15 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
export PromiseProvider from './promise';
|
||||
import Ws from './ws';
|
||||
|
||||
export Http from './http';
|
||||
export PostMessage from './postMessage';
|
||||
export Ws from './ws';
|
||||
export PromiseProvider from './promise';
|
||||
|
||||
const WsSecure = Ws;
|
||||
|
||||
export {
|
||||
Ws,
|
||||
WsSecure
|
||||
};
|
||||
|
||||
@@ -46,7 +46,7 @@ export default class PostMessage {
|
||||
}
|
||||
|
||||
subscribe = (api, callback, params) => {
|
||||
console.log('paritySubscribe', JSON.stringify(params), api, callback);
|
||||
// console.log('paritySubscribe', JSON.stringify(params), api, callback);
|
||||
return new Promise((resolve, reject) => {
|
||||
const id = ++this.id;
|
||||
|
||||
@@ -89,8 +89,10 @@ export default class PostMessage {
|
||||
}
|
||||
|
||||
if (this._messages[id].subscription) {
|
||||
console.log('subscription', result, 'initial?', this._messages[id].initial);
|
||||
this._messages[id].initial ? this._messages[id].resolve(result) : this._messages[id].callback(error && new Error(error), result);
|
||||
// console.log('subscription', result, 'initial?', this._messages[id].initial);
|
||||
this._messages[id].initial
|
||||
? this._messages[id].resolve(result)
|
||||
: this._messages[id].callback(error && new Error(error), result);
|
||||
this._messages[id].initial = false;
|
||||
} else {
|
||||
this._messages[id].callback(error && new Error(error), result);
|
||||
|
||||
@@ -14,7 +14,15 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import Ws from './ws';
|
||||
|
||||
export Http from './http';
|
||||
export Ws from './ws';
|
||||
export TransportError from './error';
|
||||
export Middleware from './middleware';
|
||||
|
||||
const WsSecure = Ws;
|
||||
|
||||
export {
|
||||
Ws,
|
||||
WsSecure
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user