Skip to content
/ jcc_rpc Public

A javascript restful api for interacting with the jingchang server

License

Notifications You must be signed in to change notification settings

JCCDex/jcc_rpc

Repository files navigation

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);

About

A javascript restful api for interacting with the jingchang server

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published