jcc_rpc
TypeScript icon, indicating that this package has built-in type declarations

0.3.2 • Public • Published

jcc_rpc

npm Build Status Coverage Status npm downloads

Installation

npm install jcc_rpc

Docs

see docs

SubscribeTask

Added SubscribeTask class since v0.2.3.

// By requesting config as an example

const { SubscribeFactory, ConfigFactory } = require("jcc_rpc");

const configInst = ConfigFactory.init(["https://jccdex.cn"]);

const subscribeInst = SubscribeFactory.init();

// task name
const TASK_NAME = "pollingConfig";
// task function
const task = configInst.getConfig.bind(configInst);
// whether polling, default true
const polling = true;
// polling interval, default 5000(ms)
const timer = 10000;

const callback = (err, res) => {
  console.log(err);
  console.log(res);
};

subscribeInst
  // register task
  .register(TASK_NAME, task, polling, timer)
  // watch task
  .on(TASK_NAME, callback)
  // start task
  .start(TASK_NAME)
  // stop polling given task
  .stopPolling(TASK_NAME)
  // remove given task
  .removeTask(TASK_NAME)
  // remove all tasks
  .removeAll()
  // stop polling all tasks
  .stopAll()
  // cancel watch
  .off(TASK_NAME, callback);

Package Sidebar

Install

npm i jcc_rpc

Weekly Downloads

4

Version

0.3.2

License

MIT

Unpacked Size

102 kB

Total Files

33

Last publish

Collaborators

  • jccdex