Imported from MrBaoquan/UNIHper (
Editor/Skills/unirx-patterns/SKILL.md). Install upstream withnpx skills add MrBaoquan/UNIHper --skill unirx-patterns. Copyright stays with the author.
UniRx Patterns
Use this skill when implementing subscriptions, reactive UI bindings, observable-based flow, or lifecycle-managed async logic.
Default Rules
- Prefer reactive bindings over imperative listener glue when the framework already exposes UniRx helpers.
- Every
Subscribemust be lifecycle-managed. - In UGUI pages, bind in
OnShown()and clear inOnHidden().
UI Binding
Get<Button>("StartButton").OnClickAsObservable()
.Subscribe(_ => OnStartClicked())
.AddTo(_disposables);
CompositeDisposable
private readonly CompositeDisposable _disposables = new CompositeDisposable();
protected override void OnHidden()
{
_disposables.Clear();
}
Key-Based Alternatives
someObservable.Subscribe(...).DisposeWith("serial-key");
obs1.Subscribe(...).AddTo("group-key");
obs2.Subscribe(...).AddTo("group-key");
Debounce And Throttle
inputField.OnValueChangedAsObservable()
.Throttle(TimeSpan.FromMilliseconds(300))
.Subscribe(OnSearch)
.AddTo(_disposables);