https://github.com/jccdex/jcc_rpc
A javascript restful api for interacting with the jingchang server
https://github.com/jccdex/jcc_rpc
cross-chain dex javascript jccdex rest-api rpc
Last synced: 6 months ago
JSON representation
A javascript restful api for interacting with the jingchang server
- Host: GitHub
- URL: https://github.com/jccdex/jcc_rpc
- Owner: JCCDex
- License: mit
- Created: 2018-08-01T09:32:55.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2023-01-04T21:37:13.000Z (over 2 years ago)
- Last Synced: 2024-12-13T19:57:17.791Z (6 months ago)
- Topics: cross-chain, dex, javascript, jccdex, rest-api, rpc
- Language: TypeScript
- Homepage:
- Size: 1.42 MB
- Stars: 5
- Watchers: 9
- Forks: 8
- Open Issues: 18
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# jcc_rpc

[](https://travis-ci.com/JCCDex/jcc_rpc)
[](https://coveralls.io/github/JCCDex/jcc_rpc?branch=master)
[](http://npm-stat.com/charts.html?package=jcc_rpc)## Installation
```javascript
npm install jcc_rpc
```## Docs
see [docs](https://github.com/JCCDex/jcc_rpc/tree/master/docs)
## SubscribeTask
Added [`SubscribeTask`](https://github.com/JCCDex/jcc_rpc/blob/master/src/subscribe.ts) class since v0.2.3.
```javascript
// By requesting config as an exampleconst { 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);
```