0.0.31 • Published 3 years ago

fireacg-core v0.0.31

Weekly downloads
-
License
LGPL-2.1
Repository
-
Last release
3 years ago

FireACG-Core-JavaScript

FireACG Core for JavaScript 项目核心创库, 提供 Api 与 Native 进行交互

Installation

// npm
npm install fireacg-core

// yarn
yarn add fireacg-core

Usage/Examples

请参考: src/__tests__/*.ts

API Reference

emit

App 调用 Native

FireACG.shared().emit(cmd: NativeCommand);
app.emit(cmd: NativeCommand);
ParameterTypeRequireDescription
cmdNativeCommandtrueNative 指令

emitHttpRequest

App 调用 Native 完成网络请求, 对 emit 的封装, 方便使用, 直接通过 emit 调用可达到同样的效果

FireACG.shared().emitHttpRequest(appName: string, a: HttpParams | URL, callback: Callback);
app.emitHttpRequest(a: HttpParams | URL, callback: Callback);
ParameterTypeRequireDescription
appNamestringtrueapp 名称
aHttpParams\|URLtruehttp 请求参数对象或者 URL 链接对象
callbackCallbacktruehttp 请求完成后的回调方法

nativeEmitCallback

app 回调 Native, Native 请求完 app 后, app 响应 Native 的请求, 如果在 app 是直接 return 结果集, 则不需要手动调用改方法

FireACG.shared().nativeEmitCallback(cmd: AppCommand);
app.nativeEmitCallback(cmd: AppCommand);
ParameterTypeRequireDescription
cmdAppCommandtrueApp 指令

callHandler

Native 调用 app 完成对应指令的业务逻辑

FireACG.shared().callHandler(cmd: AppCommand);
app.callHandler(cmd: AppCommand);
ParameterTypeRequireDescription
cmdAppCommandtrueApp 指令

emitCallback

Native 回调 app

FireACG.shared().emitCallback(cmd: NativeCommand);
app.emitCallback(cmd: NativeCommand);
ParameterTypeRequireDescription
cmdNativeCommandtrueNative 指令

addApp

添加 App, 注册到 Native

FireACG.shared().addApp(name: string, app: App);
ParameterTypeRequireDescription
namestringtrueapp 名称
appApptrueApp 对象

log

打印日志, 接管系统的日志打印工作, 以便在 Native 环境下也能正常打印日志

FireACG.shared().log(tag: string, ...args: any[]);
app.log(tag: string, ...args: any[]);
ParameterTypeRequireDescription
tagstringtrue标记, 方便查找数据
...argsany[]false需要打印的数据

parseJson

处理非标准 JSON, 转换为标准 JSON 格式

FireACG.shared().parseJson(str: string): string | null;
ParameterTypeRequireDescription
strstringtruejson 字符串

FAQ

...

0.0.31

3 years ago

0.0.30

3 years ago

0.0.29

3 years ago

0.0.20

3 years ago

0.0.21

3 years ago

0.0.23

3 years ago

0.0.24

3 years ago

0.0.26

3 years ago

0.0.27

3 years ago

0.0.28

3 years ago

0.0.16

3 years ago

0.0.17

3 years ago

0.0.18

3 years ago

0.0.19

3 years ago

0.0.14

3 years ago

0.0.15

3 years ago

0.0.13

3 years ago

0.0.10

3 years ago

0.0.11

3 years ago

0.0.12

3 years ago

0.0.9

3 years ago

0.0.8

3 years ago

0.0.7

3 years ago

0.0.3

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.6

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago