I'm new to RxSwift and reading about subjects, I tried Variable
Subject. Which in turns giving Warning in console
ℹ️ [DEPRECATED] `Variable` is planned for future deprecation. Please consider `BehaviorRelay` as a replacement. Read more at: https://git.io/vNqvx
Earlier I have declared Variable
like this
var searchItems = Variable<[MyClass]>([])
So i have done basic array operations from it's property called value
as it was get set
property like
1. self.searchItems.value.removeAll()
2. self.searchItems.value.append(items)
3. self.searchItems.value = items
Now After getting warning i changed it to BehaviorRelay
like
var searchItems = BehaviorRelay<[MyClass]>(value: [])
So I got error that value is get property only.
I googled alot but can't get suitable explanations for Array operations.
I only got a code self.searchItems.accept(items)
which i really don't know what it exactly do add fresh items or append.
I needed how all 4 operations will be performed when using BehaviorRelay
?
1) Remove all
var array = self.searchItems.value
array.removeAll()
self.searchItems.accept(array)
2) Append item
self.searchItems.value.accept(searchItems + [items])
3) Value = ...
self.searchItems.value.accept(items)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With