-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconsumers.js
42 lines (37 loc) · 1020 Bytes
/
consumers.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// @themost-framework 2.0 Codename Blueshift Copyright (c) 2017-2025, THEMOST LP All rights reserved
var _ = require('lodash');
/**
* @class
* @param {Function} callable
* @param {*=} params
* @constructor
*/
function HttpConsumer(callable, params) {
/**
* IMPORTANT NOTE FOR HTTP CONSUMERS
* (this an instance of HttpContext)
var consumer = new HttpConsumer(function() {
console.log(this.request.url)
});
*/
if (!_.isFunction(callable)) {
throw new TypeError('Consumer must be a function');
}
/**
* @type {Function}
*/
this.callable = callable;
/**
* Gets or sets the parameters associated with this consumer
*/
this.params = params;
}
/**
* @param {*} context
* @param {...*} args
*/
// eslint-disable-next-line no-unused-vars
HttpConsumer.prototype.run = function(context, args) {
return this.callable.apply(context, Array.prototype.slice.call(arguments));
};
module.exports.HttpConsumer = HttpConsumer;