Skip to content

Commit bf0dfd0

Browse files
committed
refactor(realtime): add more debug logs
1 parent 5b4def6 commit bf0dfd0

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/realtime.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import Connection, {
1616
import { ErrorCode, createError } from './error';
1717
import { tap, Cache, trim, internal, ensureArray, isWeapp } from './utils';
1818
import { applyDecorators, applyDispatcher } from './plugin';
19+
import { version as VERSION } from '../package.json';
1920

2021
const debug = d('LC:Realtime');
2122
const debugRequest = d('LC:request');
@@ -37,8 +38,8 @@ export default class Realtime extends EventEmitter {
3738
* @param {String|String[]} [options.RTMServers] 指定私有部署的 RTM 服务器地址(since 4.0.0)
3839
* @param {Plugin[]} [options.plugins] 加载插件(since 3.1.0)
3940
*/
40-
constructor(options) {
41-
debug('initializing Realtime');
41+
constructor({ plugins, ...options }) {
42+
debug('initializing Realtime %s %O', VERSION, options);
4243
super();
4344
if (typeof options.appId !== 'string') {
4445
throw new TypeError(`appId [${options.appId}] is not a string`);
@@ -60,10 +61,12 @@ export default class Realtime extends EventEmitter {
6061
);
6162
this._cache = new Cache('endpoints');
6263
internal(this).clients = new Set();
63-
this._plugins = [
64+
const mergedPlugins = [
6465
...ensureArray(Realtime.__preRegisteredPlugins),
65-
...ensureArray(options.plugins),
66-
].reduce((result, plugin) => {
66+
...ensureArray(plugins),
67+
];
68+
debug('Using plugins %o', mergedPlugins.map(plugin => plugin.name));
69+
this._plugins = mergedPlugins.reduce((result, plugin) => {
6770
// eslint-disable-next-line no-restricted-syntax
6871
for (const hook in plugin) {
6972
if ({}.hasOwnProperty.call(plugin, hook) && hook !== 'name') {

0 commit comments

Comments
 (0)