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

fh-wfm-mediator

Package Overview
Dependencies
Maintainers
3
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fh-wfm-mediator - npm Package Compare versions

Comparing version 0.3.0-rc2 to 0.3.0-rc3

10

lib/angular/mediator-ng.js
"use strict";
const angular = require("angular");
const mediator = require("../mediator");
var angular = require("angular");
var mediator = require("../mediator");
angular.module('wfm.core.mediator', ['ng'])
.factory('mediator', function mediatorService($q) {
let originalRequest = mediator.request;
var originalRequest = mediator.request;
// monkey patch the request function, wrapping the returned promise as an angular promise
mediator.request = function () {
let promise = originalRequest.apply(mediator, arguments);
var promise = originalRequest.apply(mediator, arguments);
return $q.when(promise);
};
mediator.subscribeForScope = function (topic, scope, fn) {
let subscriber = mediator.subscribe(topic, fn);
var subscriber = mediator.subscribe(topic, fn);
scope.$on('$destroy', function () {

@@ -15,0 +15,0 @@ mediator.remove(topic, subscriber.id);

"use strict";
const mediator_1 = require("./mediator");
let mediator = new mediator_1.default();
var mediator_1 = require("./mediator");
var mediator = new mediator_1.default();
module.exports = mediator;
//# sourceMappingURL=index.js.map
"use strict";
const Promise = require("bluebird");
const _ = require("lodash");
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var Promise = require("bluebird");
var _ = require("lodash");
// tslint:disable-next-line:no-var-requires
const mediatorJs = require('mediator-js');
var mediatorJs = require('mediator-js');
exports.Base = mediatorJs.Mediator;
class Mediator extends exports.Base {
var Mediator = (function (_super) {
__extends(Mediator, _super);
function Mediator() {
return _super !== null && _super.apply(this, arguments) || this;
}
/**

@@ -14,8 +23,8 @@ * A version of {@link once} that returns a Promise

*/
promise(channel, options, context) {
let self = this;
Mediator.prototype.promise = function (channel, options, context) {
var self = this;
return new Promise(function (resolve) {
self.once(channel, resolve, options, context);
});
}
};
;

@@ -42,5 +51,6 @@ /**

*/
request(topic, parameters, options = {}) {
const self = this;
const topics = {
Mediator.prototype.request = function (topic, parameters, options) {
if (options === void 0) { options = {}; }
var self = this;
var topics = {
done: options.doneTopic || 'done:' + topic,

@@ -50,4 +60,4 @@ error: options.errorTopic || 'error:' + topic,

};
const subs = {};
let uid = null;
var subs = {};
var uid = null;
if (_.has(options, 'uid')) {

@@ -75,3 +85,3 @@ uid = options.uid;

}
let args = [topics.request];
var args = [topics.request];
if (parameters instanceof Array) {

@@ -83,3 +93,3 @@ Array.prototype.push.apply(args, parameters);

}
let returnPromise = new Promise(function (resolve, reject) {
var returnPromise = new Promise(function (resolve, reject) {
subs.done = self.once(topics.done, resolve);

@@ -94,7 +104,8 @@ subs.error = self.once(topics.error, reject);

});
}
};
;
}
return Mediator;
}(exports.Base));
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = Mediator;
//# sourceMappingURL=mediator.js.map
"use strict";
const Promise = require("bluebird");
const _ = require("lodash");
class Topics {
constructor(mediator) {
var Promise = require("bluebird");
var _ = require("lodash");
var Topics = (function () {
function Topics(mediator) {
this.mediator = mediator;

@@ -15,6 +15,6 @@ this.subscriptions = {};

*/
withPrefix(prefix) {
Topics.prototype.withPrefix = function (prefix) {
this.prefix = prefix;
return this;
}
};
;

@@ -29,6 +29,6 @@ /**

*/
withEntity(entity) {
Topics.prototype.withEntity = function (entity) {
this.entity = entity;
return this;
}
};
;

@@ -40,5 +40,5 @@ /**

*/
addSubscription(topic, fn) {
Topics.prototype.addSubscription = function (topic, fn) {
this.subscriptions[topic] = this.mediator.subscribe(topic, fn);
}
};
;

@@ -52,5 +52,5 @@ /**

*/
getTopic(topicName, prefix) {
Topics.prototype.getTopic = function (topicName, prefix) {
// create, done => done:wfm:user:create
let parts = _.compact([this.prefix, this.entity, topicName]);
var parts = _.compact([this.prefix, this.entity, topicName]);
if (prefix) {

@@ -60,3 +60,3 @@ parts.unshift(prefix);

return parts.join(':');
}
};
;

@@ -72,7 +72,7 @@ /**

*/
on(method, fn) {
let topic = this.getTopic(method);
Topics.prototype.on = function (method, fn) {
var topic = this.getTopic(method);
this.addSubscription(topic, this.wrapInMediatorPromise(method, fn));
return this;
}
};
;

@@ -85,7 +85,7 @@ /**

*/
onDone(method, fn) {
let topic = this.getTopic(method, 'done');
Topics.prototype.onDone = function (method, fn) {
var topic = this.getTopic(method, 'done');
this.addSubscription(topic, fn.bind(this));
return this;
}
};
;

@@ -98,7 +98,7 @@ /**

*/
onError(method, fn) {
let topic = this.getTopic(method, 'error');
Topics.prototype.onError = function (method, fn) {
var topic = this.getTopic(method, 'error');
this.addSubscription(topic, fn.bind(this));
return this;
}
};
;

@@ -108,5 +108,5 @@ /**

*/
unsubscribeAll() {
let subId;
for (let topic in this.subscriptions) {
Topics.prototype.unsubscribeAll = function () {
var subId;
for (var topic in this.subscriptions) {
if (this.subscriptions.hasOwnProperty(topic)) {

@@ -117,3 +117,3 @@ subId = this.subscriptions[topic].id;

}
}
};
;

@@ -127,5 +127,5 @@ /**

*/
request(topic, params, options) {
Topics.prototype.request = function (topic, params, options) {
return this.mediator.request(this.getTopic(topic), params, options);
}
};
;

@@ -139,4 +139,4 @@ /**

*/
wrapInMediatorPromise(method, fn) {
const self = this;
Topics.prototype.wrapInMediatorPromise = function (method, fn) {
var self = this;
function publishDone(result) {

@@ -146,3 +146,3 @@ if (_.isUndefined(result)) {

}
let topic = self.getTopic(method, 'done');
var topic = self.getTopic(method, 'done');
if (_.has(result, 'id')) {

@@ -158,3 +158,3 @@ topic = [topic, result.id].join(':');

function publishError(error) {
let topic = self.getTopic(method, 'error');
var topic = self.getTopic(method, 'error');
if (_.has(error, 'id')) {

@@ -170,6 +170,7 @@ topic = [topic, error.id].join(':');

};
}
}
};
return Topics;
}());
;
module.exports = Topics;
//# sourceMappingURL=index.js.map
{
"name": "fh-wfm-mediator",
"version": "0.3.0-rc2",
"version": "0.3.0-rc3",
"description": "An implementation of the mediator pattern for use with WFM",

@@ -5,0 +5,0 @@ "main": "lib/angular/mediator-ng.js",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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