mirror of
https://github.com/parnic/node-intellicenter.git
synced 2025-06-16 10:10:13 -05:00
This allows require() and import to work for even better compatibility between CJS and ESM consumers. I dislike that this kills our ability for top-level awaits in example.ts, but seeing as how my primary use case for this library is a commonjs module, I think this is a fair trade-off. Also changed "messages" to not encapsulate its export under the name "messages" to remove some repetition in importing "messages" and still needing to do "messages." to get the methods out. Now it's simple to import each message by name or group them under something like "messages" as desired on a per-library-user basis. Refs: * https://www.kravchyk.com/typescript-npm-package-json-exports/ * https://arethetypeswrong.github.io/ * https://evertpot.com/universal-commonjs-esm-typescript-packages/
35 lines
1.2 KiB
JavaScript
35 lines
1.2 KiB
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.SubscribeToUpdates = SubscribeToUpdates;
|
|
const request_js_1 = require("./request.js");
|
|
/**
|
|
* Requests to subscribe for updates to the given keys.
|
|
*
|
|
* Keys and objnam should be given matching an objnam known to the controller and a key for that object.
|
|
* {@linkcode ICParam} fields are the known list of keys available to subscribe to.
|
|
*
|
|
* The response contains an acknowledgement of success or failure. When the given keys change, the `Unit` will
|
|
* emit a `"notify"` event with an {@linkcode ICResponse} payload for the new values.
|
|
*
|
|
* @param objnam the name of the object to subscribe to updates on
|
|
* @param keys the key or list of keys to subscribe to updates on this object for
|
|
* @returns the object used to issue this request
|
|
*/
|
|
function SubscribeToUpdates(objnam, keys) {
|
|
const req = (0, request_js_1.GetRequest)();
|
|
req.command = "RequestParamList";
|
|
req.objectList = [];
|
|
let ks;
|
|
if (Array.isArray(keys)) {
|
|
ks = keys;
|
|
}
|
|
else {
|
|
ks = [keys];
|
|
}
|
|
const reqObj = new request_js_1.ICRequestObj();
|
|
reqObj.objnam = objnam;
|
|
reqObj.keys = ks;
|
|
req.objectList.push(reqObj);
|
|
return req;
|
|
}
|
|
//# sourceMappingURL=notify.js.map
|