Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

connection-dashboard-extension-worona

Package Overview
Dependencies
Maintainers
2
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

connection-dashboard-extension-worona - npm Package Compare versions

Comparing version 1.3.0 to 1.3.1

5

package.json
{
"name": "connection-dashboard-extension-worona",
"version": "1.3.0",
"version": "1.3.1",
"description": "Extension for the Worona Dashboard in charge of the connection to the server.",

@@ -38,6 +38,5 @@ "scripts": {

"dependencies": {
"asteroid": "^2.0.2",
"ws": "^1.1.0"
"worona-asteroid": "^1.0.1"
},
"devDependencies": {}
}

4

src/dashboard/actions/index.js
import * as types from '../types';
import stringifyError from 'stringify-error-message';

@@ -7,4 +6,3 @@ export const connectionStarted = () => ({ type: types.CONNECTION_STARTED });

export const connectionSucceed = () => ({ type: types.CONNECTION_SUCCEED });
export const connectionFailed = errorObj =>
({ type: types.CONNECTION_FAILED, error: stringifyError(errorObj) });
export const connectionFailed = error => ({ type: types.CONNECTION_FAILED, error });
export const disconnected = error => ({ type: types.DISCONNECTED, error });
import { isRemote } from 'worona-deps';
export const url = isRemote ? 'wss://meteor.worona.io/websocket' : 'ws://localhost:3000/websocket';
export const endpoint = isRemote ? 'wss://meteor.worona.io/websocket' : 'ws://localhost:3000/websocket';
export const timeout = 10000;
/* eslint-disable class-methods-use-this */
import { createClass } from 'asteroid';
import { eventChannel } from 'redux-saga';
import { url } from '../config';
import Connection from 'worona-asteroid';
import { endpoint } from '../config';
const Asteroid = createClass();
const connection = new Connection({ endpoint });
export class Connection {
constructor(options = {}) {
this.url = options.url || url;
this.client = null;
}
start() {
this.client = new Asteroid({
autoConnect: false,
autoReconnect: false,
maintainCollections: true,
ddpVersion: '1',
endpoint: this.url,
});
}
connect() {
this.client.ddp.connect();
}
connectedEventChannel() {
return eventChannel(listener => {
const connected = this.client.ddp.on('connected', () => {
listener('connected');
});
return () => {
this.client.ddp.removeListener('connected', connected);
};
});
}
disconnectedEventChannel() {
return eventChannel(listener => {
const disconnected = this.client.ddp.on('disconnected', () => {
listener('disconnected');
});
return () => {
this.client.ddp.removeListener('disconnected', disconnected);
};
});
}
call(...params) {
return new Promise((resolve, reject) => {
this.client.call(...params)
.then(result => {
if (typeof result === 'object' && result.errorType === 'Meteor.Error') {
reject(result);
} else {
resolve(result);
}
})
.catch(error => reject(error));
});
}
loginWithPassword(email, password) {
return this.client.loginWithPassword({ email, password });
}
loggedInEventChannel() {
return eventChannel(listener => {
const loggedIn = this.client.on('loggedIn', () => {
listener(this.client.userId);
});
return () => {
this.client.removeListener('loggedIn', loggedIn);
};
});
}
loggedOutEventChannel() {
return eventChannel(listener => {
const loggedOut = this.client.on('loggedOut', () => {
listener('logout');
});
return () => {
this.client.removeListener('loggedOut', loggedOut);
};
});
}
logout() {
return this.client.logout();
}
subscribe(...params) {
return this.client.subscribe(...params);
}
unsubscribe(id) {
this.client.unsubscribe(id);
}
collectionEventChannel(selectedCollection) {
return eventChannel(listener => {
const added = this.client.ddp.on('added', ({ collection, id, fields }) => {
if (collection === selectedCollection) {
listener({ collection: selectedCollection, event: 'added', id, fields });
}
});
const changed = this.client.ddp.on('changed', ({ collection, id, fields }) => {
if (collection === selectedCollection) {
listener({ collection: selectedCollection, event: 'changed', id, fields });
}
});
const removed = this.client.ddp.on('removed', ({ collection, id, fields }) => {
if (collection === selectedCollection) {
listener({ collection: selectedCollection, event: 'removed', id, fields });
}
});
return () => {
this.client.ddp.removeListener('added', added);
this.client.ddp.removeListener('changed', changed);
this.client.ddp.removeListener('removed', removed);
};
});
}
readyEventChannel(subscription) {
return eventChannel(listener => {
const ready = subscription.on('ready', () => {
listener({ subscription: subscription.name });
});
return () => {
subscription.removeListener('ready', ready);
};
});
}
errorEventChannel(subscription) {
return eventChannel(listener => {
const error = subscription.on('error', err => {
listener({ subscription: subscription.name, error: err });
});
return () => {
subscription.removeListener('error', error);
};
});
}
}
const connection = new Connection();
export const start = connection.start.bind(connection);

@@ -152,0 +8,0 @@ export const connect = connection.connect.bind(connection);

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc