nativescript-ably
ably.io 实时通信系统的包装器
npm i --save nativescript-ably

NativeScript Ably 插件

ably.io 库的 Android 和 IOS 包装器

策略

目标是分离 API 和实现

  • api 文件夹用于公共和 API 声明
  • impl 文件夹用于实现
  • ably.android.ts 和 ably.ios.ts 初始化适当的平台实现
  • ably.d.ts 提供从 API 派生的 TypeScript 定义。

应用程序只需要导入 nativescript-ably 模块。示例

import {AblyRealtime, Message, ConnectionStateChange, ConnectionState} from "nativescript-ably"

它将导入由 ably.android.ts 或 ably.ios.ts 生成的 ably.js 文件。具体取决于平台

您不应该

Import the API folder, unless you are exposing the API in a implementation
Import the implementation folder, unless you know what you are doing :-)

首先添加 Android 实现,在学习 API 后,进行测试,然后添加 IOS

演示

https://github.com/atende/nativescript-ably-demo

典型开发工作流程

git clone https://github.com/atende/nativescript-ably
git clone https://github.com/atende/nativescript-ably-demo
cd nativescript-ably
tsc --watch
cd ../nativescript-ably-demo
  1. 修改插件文件
  2. demo 中进行修改,以测试这些更改
  3. npm run live.androidnpm run live.ios (必须从 demo 目录运行)

这些 demo 任务只是通用助手。您可能希望对要运行的设备/模拟器有更细粒度的控制。为此,您可以手动运行

cd demo

// when developing, to ensure the latest code is built into the demo, it's a gaurantee to remove the plugin and add it back
tns plugin remove nativescript-ably // replace with your plugin name
tns plugin add ../nativescript-ably

// manual platform adds
tns platform add ios
// and/or
tns platform add android

然后使用 tns 命令行中的任何可用选项