gpt4 book ai didi

android - RxSwift 类似于 Android 的 Actions

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:29:27 24 4
gpt4 key购买 nike

几年前,我第一次接触到 ReactiveCocoa 的响应式(Reactive)编程。在那里,他们有了关于 RACCommand 的概念,它通过扩展库 Action 被转移到 RxSwift .

如他们的 GitHub 页面所述:

An action is a way to say "hey, later I'll need you to subscribe to this thing."

Actions accept a workFactory: a closure that takes some input and produces an observable. When execute() is called, it passes its parameter to this closure and subscribes to the work.

  • Can only be executed while "enabled" (true if unspecified).
  • Only execute one thing at a time.
  • Aggregates next/error events across individual executions.

根据我的经验,在进行稳健的响应式 iOS 开发时,它绝对是响应式编程工具箱中必不可少的工具。


现在我们也想将其转移到 Android 应用程序中。但经过无数小时的研究,我一直无法为 RxJavaRxKotlin 找到相应的组件。

Swift 中的实现相对简单,所以我们可以直接移植它,但我首先想听听是否:

  1. 这真的不存在,如果是的话
  2. 是否有 Android 特定原因导致它不存在,即移植它的原因

最佳答案

我们最终自己移植了 iOS 版本。

它是开源的,可以在这里找到: https://github.com/tonsser/kaction

关于android - RxSwift 类似于 Android 的 Actions,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49031599/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com