com um clique
harlan-rn-architecture
Harlan 个人 RN 容器架构设计偏好和思想 - 协议优于继承、拒绝兼容性代码、单一职责原则
Instalar com Codex ou Claude Copie este prompt, cole no Codex, Claude ou outro assistente e deixe que ele revise a página da skill e instale para você.
Menu
Harlan 个人 RN 容器架构设计偏好和思想 - 协议优于继承、拒绝兼容性代码、单一职责原则
Instalar com Codex ou Claude Copie este prompt, cole no Codex, Claude ou outro assistente e deixe que ele revise a página da skill e instale para você.
Baseado na classificação ocupacional SOC
Use when designing, reviewing, or refactoring code architecture and engineering structure, especially when logic is leaking into the wrong layer, UI components contain business rules, orchestration services do data parsing, one bug hints at a reusable abstraction, or a feature needs clear boundaries between data source, transformation, state management, extension points, and rendering. Use for separation of concerns, layered design, parser/adapter/pipeline decisions, reusable contracts, and preventing narrow fixes from becoming hardcoded architecture.
智能分析工作区变更,自动生成符合 Conventional Commits 规范的精炼提交信息并执行提交。
Review staged, unstaged, and untracked local code changes in the current project. Use when the user asks to review uncommitted changes, check the working tree, inspect local diffs, or perform a pre-commit code review.
Generate or update Ninebot iOS VApp native methods and services. Use when adding a Swift VApp API, creating a VApp-backed pod under ios/Modules, exposing native methods through NBVAppManager/NBUnifiedAPIRegistry, wiring registrations in RootVCService+vapp.swift, or converting RN/callnative methods to the VApp service pattern.
Git commit workflow with conventional format and comprehensive summaries
Harlan 的通用架构设计哲学 — 指导 AI 在任何架构任务中遵循 Harlan 的设计偏好、决策风格和输出格式。适用于系统设计、重构、模块拆分、API 设计等所有架构级别的任务。
| name | harlan-rn-architecture |
| description | Harlan 个人 RN 容器架构设计偏好和思想 - 协议优于继承、拒绝兼容性代码、单一职责原则 |
| origin | custom |
RNMethodHandler 协议替代 RNCommonModule 继承RNMethodDispatcher 只负责分发NBVAppManager 只负责服务管理NBPermissionCenter 只负责权限检查@objc 方法全部可被调用,无法精确控制registeredMethods() 明确声明暴露的方法NBVAppManager.service(for:)RNMethodDispatcher.shared.register(XXXHandler.self)RNMethodDispatcher (单例)
├── 接收 RNCallNative 通知
├── 字典查找 registrations[methodName] - O(1)
└── 调用 handler.handle()
RNMethodHandler (协议)
├── registeredMethods() -> [String] // 声明暴露的方法
└── handle(method:params:completion:) // 处理调用
NBVAppManager (外部框架)
└── service(for:) // 获取真实服务实例
注册机制
RNMethodHandler 协议registeredMethods() 中声明要暴露的方法register() 进行注册分发流程
RNCallNative 通知
↓
RNMethodDispatcher.handleRNCallNative()
↓
字典查找 registrations[methodName] ← O(1)
↓
handler.handle(method:params:completion:)
↓
NBVAppManager.service(for:) 获取服务
↓
completion(.success(result))
↓
RNCallBack 通知 → JS 侧
错误处理
.methodNotFound.invocationFailedpublic class RNXXXModule: RNCommonModule {
@objc func methodA(_ userInfo: RNModel) {
// 原有逻辑
}
}
final class RNXXXHandler: RNMethodHandler {
func registeredMethods() -> [String] {
return ["methodA"]
}
func handle(method: String, params: [String: Any]?,
completion: @escaping (Result<Any?, RNMethodError>) -> Void) {
switch method {
case "methodA":
handleMethodA(params: params, completion: completion)
default:
completion(.failure(.methodNotFound(method: method)))
}
}
private func handleMethodA(params: [String: Any]?,
completion: @escaping (Result<Any?, RNMethodError>) -> Void) {
// 原有逻辑,最后调用 completion()
}
}
RNMethodHandler 协议registeredMethods() 列出所有方法名handle() 中用 switch-case 分发@objc,参数从 RNModel 改为 params: [String: Any]?completion() 而非 NotificationCenter.post| 文件 | 职责 |
|---|---|
RNMethodError.swift | 错误类型枚举 |
RNMethodHandler.swift | 方法处理协议 |
RNMethodRegistration.swift | 注册数据结构 |
RNMethodDispatcher.swift | 核心分发器(单例) |
RNCommonModule 继承方式造成强耦合RNMethodHandler 协议NBVAppManager 负责NBVAppManager.service(for:) 调用