How to use BehaviorRelay as an alternate to Variable in RxSwift?

后端 未结 8 1941
无人共我
无人共我 2021-01-30 03:52

As of RxSwift4, Variable is moved to Deprecated.swift marking the possible deprecation of Variable in future. An alternate proposed to

8条回答
  •  灰色年华
    2021-01-30 04:35

    Building on Dalton's answer, here is a handy extension:

    extension BehaviorRelay where Element: RangeReplaceableCollection {
        func acceptAppending(_ element: Element.Element) {
            accept(value + [element])
        }
    }
    

提交回复
热议问题