— No reviews yet
0 installs
7 views
0.0% view→install
Install
$ agentstack add skill-mythkiven-figma-ios-codegen-figma-ios-rxswift-interaction-pattern ✓ scanned · ✓ verified — works with Claude Code, Cursor, and more.
Security review
✓ PassedNo issues found. Passed automated security review. · v0.1.0 How review works →
- ✓ Prompt-injection patterns
- ✓ Secret / credential exfiltration
- ✓ Dangerous shell & filesystem operations
- ✓ Untrusted network calls
- ✓ Known-malicious package signatures
What it can access
- ✓ Network access No
- ✓ Filesystem access No
- ✓ Shell / process execution No
- ✓ Environment & secrets No
- ✓ Dynamic code execution No
From automated source analysis of v0.1.0. “Used” means the capability is present in the source — more access means more to trust, not that it’s unsafe.
Are you the author of Figma Ios Rxswift Interaction Pattern? Claim this listing to set pricing, connect Stripe payouts, and keep 70% of every sale.
Sign up to claimAbout
交互模式(默认示例:target-action;Rx 仅当 host.interaction=rxswift)
> 以 host.json → interaction 为准。target_action 用下方「传统写法」;仅配置为 rxswift 时用 Rx 示例。 > 不要强制写 import;需要 Rx 时由生成代码按工程依赖自行引入。
传统写法(host.interaction = target_action,默认)
button.addTarget(self, action: #selector(onTap), for: .touchUpInside)
@objc private func onTap() {
// ...
}
Rx 写法(仅 host.interaction = rxswift)
依赖与 import 由宿主工程已具备时再使用,skill 不强制写死:
标准写法
1. 在 ViewController 或 View 中声明 DisposeBag
import UIKit
import RxSwift
import RxCocoa
class AppDemoViewController: UIViewController {
private let disposeBag = DisposeBag()
// ...
}
2. 按钮点击事件
private func setupBindings() {
submitButton.rx.tap
.subscribe(onNext: { [weak self] in
self?.handleSubmitTapped()
})
.disposed(by: disposeBag)
}
3. 手势事件
let tapGesture = UITapGestureRecognizer()
view.addGestureRecognizer(tapGesture)
tapGesture.rx.event
.subscribe(onNext: { [weak self] _ in
self?.handleTapped()
})
.disposed(by: disposeBag)
4. UITextField / UITextView 文本变化
textField.rx.text.orEmpty
.subscribe(onNext: { [weak self] text in
self?.handleTextChanged(text)
})
.disposed(by: disposeBag)
5. UIControl 通用事件
stepper.rx.controlEvent(.valueChanged)
.subscribe(onNext: { [weak self] in
self?.handleValueChanged()
})
.disposed(by: disposeBag)
与传统 target-action 的对比
传统写法(仍可用,但不推荐)
button.addTarget(self, action: #selector(handleTapped), for: .touchUpInside)
@objc private func handleTapped() {
// ...
}
RxSwift 写法(推荐)
button.rx.tap
.subscribe(onNext: { [weak self] in
self?.handleTapped()
})
.disposed(by: disposeBag)
private func handleTapped() {
// ...
}
优势:
- 不需要
@objc标记 - 事件绑定统一在
setupBindings()中,清晰 - 支持链式操作(如防抖、合并多个事件等)
防抖与节流
防抖(debounce)- 避免频繁点击
button.rx.tap
.debounce(.milliseconds(300), scheduler: MainScheduler.instance)
.subscribe(onNext: { [weak self] in
self?.handleSubmitTapped()
})
.disposed(by: disposeBag)
节流(throttle)- 限制频率
button.rx.tap
.throttle(.seconds(1), scheduler: MainScheduler.instance)
.subscribe(onNext: { [weak self] in
self?.handleButtonTapped()
})
.disposed(by: disposeBag)
注意事项
- DisposeBag:必须声明为实例属性,不要用局部变量(会导致订阅立即取消)
- [weak self]:闭包中捕获 self 时始终用
[weak self],避免循环引用 - 线程:UI 事件默认在主线程;若涉及后台任务,用
.observeOn(MainScheduler.instance)切回主线程更新 UI
相关
- 总入口:[figma-ios-playbook](../figma-ios-playbook/SKILL.md)
- ViewController 基类 + 导航栏:[figma-ios-navigation](../figma-ios-navigation/SKILL.md)
- 选中态交互逻辑:[figma-ios-selection-interaction](../figma-ios-selection-interaction/SKILL.md)(使用本 Skill 的事件绑定模式实现选中态切换)
Source & license
This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.
- Author: mythkiven
- Source: mythkiven/figma-ios-codegen
- License: MIT
- Homepage: https://github.com/mythkiven/figma-ios-codegen/tree/main/docs
Install and usage instructions live in the source repository linked above.
Reviews
No reviews yet — be the first.
Write a review
Versions
- v0.1.0 Imported from the upstream source.