0.0.31 • Published 5 years ago
fireacg-core v0.0.31
FireACG-Core-JavaScript
FireACG Core for JavaScript 项目核心创库, 提供 Api 与 Native 进行交互
Installation
// npm
npm install fireacg-core
// yarn
yarn add fireacg-coreUsage/Examples
请参考: src/__tests__/*.ts
API Reference
emit
App 调用 Native
FireACG.shared().emit(cmd: NativeCommand);
app.emit(cmd: NativeCommand);| Parameter | Type | Require | Description |
|---|---|---|---|
cmd | NativeCommand | true | Native 指令 |
emitHttpRequest
App 调用 Native 完成网络请求, 对 emit 的封装, 方便使用, 直接通过 emit 调用可达到同样的效果
FireACG.shared().emitHttpRequest(appName: string, a: HttpParams | URL, callback: Callback);
app.emitHttpRequest(a: HttpParams | URL, callback: Callback);| Parameter | Type | Require | Description |
|---|---|---|---|
appName | string | true | app 名称 |
a | HttpParams\|URL | true | http 请求参数对象或者 URL 链接对象 |
callback | Callback | true | http 请求完成后的回调方法 |
nativeEmitCallback
app 回调 Native, Native 请求完 app 后, app 响应 Native 的请求, 如果在 app 是直接 return 结果集, 则不需要手动调用改方法
FireACG.shared().nativeEmitCallback(cmd: AppCommand);
app.nativeEmitCallback(cmd: AppCommand);| Parameter | Type | Require | Description |
|---|---|---|---|
cmd | AppCommand | true | App 指令 |
callHandler
Native 调用 app 完成对应指令的业务逻辑
FireACG.shared().callHandler(cmd: AppCommand);
app.callHandler(cmd: AppCommand);| Parameter | Type | Require | Description |
|---|---|---|---|
cmd | AppCommand | true | App 指令 |
emitCallback
Native 回调 app
FireACG.shared().emitCallback(cmd: NativeCommand);
app.emitCallback(cmd: NativeCommand);| Parameter | Type | Require | Description |
|---|---|---|---|
cmd | NativeCommand | true | Native 指令 |
addApp
添加 App, 注册到 Native
FireACG.shared().addApp(name: string, app: App);| Parameter | Type | Require | Description |
|---|---|---|---|
name | string | true | app 名称 |
app | App | true | App 对象 |
log
打印日志, 接管系统的日志打印工作, 以便在 Native 环境下也能正常打印日志
FireACG.shared().log(tag: string, ...args: any[]);
app.log(tag: string, ...args: any[]);| Parameter | Type | Require | Description |
|---|---|---|---|
tag | string | true | 标记, 方便查找数据 |
...args | any[] | false | 需要打印的数据 |
parseJson
处理非标准 JSON, 转换为标准 JSON 格式
FireACG.shared().parseJson(str: string): string | null;| Parameter | Type | Require | Description |
|---|---|---|---|
str | string | true | json 字符串 |
FAQ
...
0.0.31
5 years ago
0.0.30
5 years ago
0.0.29
5 years ago
0.0.20
5 years ago
0.0.21
5 years ago
0.0.23
5 years ago
0.0.24
5 years ago
0.0.26
5 years ago
0.0.27
5 years ago
0.0.28
5 years ago
0.0.16
5 years ago
0.0.17
5 years ago
0.0.18
5 years ago
0.0.19
5 years ago
0.0.14
5 years ago
0.0.15
5 years ago
0.0.13
5 years ago
0.0.10
5 years ago
0.0.11
5 years ago
0.0.12
5 years ago
0.0.9
5 years ago
0.0.8
5 years ago
0.0.7
5 years ago
0.0.3
5 years ago
0.0.5
5 years ago
0.0.4
5 years ago
0.0.6
5 years ago
0.0.2
5 years ago
0.0.1
5 years ago