RxDataSources | UICollectionView Data Sources for RxSwift ( sections | Animation library
kandi X-RAY | RxDataSources Summary
kandi X-RAY | RxDataSources Summary
UITableView and UICollectionView Data Sources for RxSwift (sections, animated updates, editing ...)
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of RxDataSources
RxDataSources Key Features
RxDataSources Examples and Code Snippets
Community Discussions
Trending Discussions on RxDataSources
QUESTION
I have some odd problem with UITableViewCell
when I use MVVM pattern with RxSwift. I can't describe it, but I will try to explain.
Let's say we have simple UITableViewCell
...ANSWER
Answered 2022-Mar-17 at 00:02You implemented your ItemMode.==
incorrectly. It doesn't actually check for equality, it only checks the identity. Remove the function and let the compiler generate the correct one for you.
QUESTION
I have an enum with associated values, which I want to use as an item in RxDataSources. I tried conforming it to identifiable by conforming it to Hashable like below
...ANSWER
Answered 2022-Mar-01 at 15:14You have confused Identifiable
, a Swift built-in protocol, with IdentifiableType
, a protocol in the RxDataSource library.
You can just conform to IdentifiableType
.
QUESTION
I am using RxDatasources
to create my datasource. Later on, I configure cells in my view controller. The thing is, cause headers/footers has nothing with datasource (except we can set a title, but if we use custom header footer, this title will be overriden).
Now, this is how I configure my tableview cells:
...ANSWER
Answered 2022-Feb-20 at 23:38The fundamental issue here is that tableView(_:viewForHeaderInSection:)
is a pull based method and Rx is designed for push based systems. Obviously it can be done. After all, the base library did it for tableView(_:cellForRowAt:)
but it's quite a bit more complex. You can follow the same system that the base library uses for the latter function.
Below is such a system. It can be used like this:
QUESTION
I wasn't really able to find this in docs or somewhere, but is there a way to provide custom header and footer loaded from nib, using RxDatasources?
For example, I am dequeuing a cell like this:
...ANSWER
Answered 2021-Dec-28 at 13:04A custom Header/Footer is not part of the UITableViewDataSource interface so it's not something that an RxDataSource can provide.
If you want, you can follow my article on how to Convert a Swift Delegate to RxSwift Observables and make a table view delegate for this... It's not part of the library because table view delegates don't conform to a push interface.
QUESTION
I am having a behavior relay in my view model that is used as a source of data. Its defined like this:
...ANSWER
Answered 2021-Dec-25 at 15:16You have defined your Equatable conformance incorrectly in the PostCellModel
. Because of that, the system is unable to tell whether a cell model has changed... Remove your manually defined ==(lhs:rhs:)
and let the system generate them for you and you should be fine...
QUESTION
I am trying to make multiple sections (two actually) using RxDatasources. Usually with one section, I would go like this:
Section model:
...ANSWER
Answered 2021-Dec-16 at 19:44Here is a kind of worst case situation. You might be able to simplify this code depending on your use case:
QUESTION
I have a list of models that I fetch from a server, and basically I get array of these:
...ANSWER
Answered 2021-Nov-23 at 13:08You have to replace the contacts that have changed; all the contacts that were changed, but you can't do that because you aren't tracking all of them, only the most recent one. So you can't do it in a map. You need to use scan
instead.
I made a lot of assumptions about code you didn't post, so the below is a compilable example. If your types are different, then you will have to make some changes:
QUESTION
Problem: CollectionView header and footer are not shown before results are retrieved from network service. They are shown after items are retrieved from service.
Result I want:: Show CollectionView header and footer before items are retrieved from api call
What i've tried: Used different datasource with header and footer on initial viewDidLoad and set that datasource to nil when results loaded. Didn't work
My (not so elegant) solution: Add headerView and footerView subviews on viewDidLoad and replace them with collectionView when results come from service.
...ANSWER
Answered 2021-Jan-26 at 02:49The simple solution, and I feel more elegant, is to use startWith
to emit an array of SectionModel
s that each have 0 items, but have the model
contain the right value.
QUESTION
I have a BehaviorSubject
where my tableview is bound to through RxDataSources.
Besides that, I have a pull to refresh which creates an observable that updates the data and updates the data in the BehaviorSubject
so that my UITableView updates correctly.
Now the question is, how do I handle the error handling for whenever my API call fails?
Few options that I have thought of was:
- Subscribe to the observer's
onError
and call theonError
of myBehaviorSubject
\ - Somehow try to
concat
? orbind(to: ..)
- Let another subscriber in my
ViewController
subscribe besides that my tableview subscribes to theBehaviorSubject
.
Any suggestions?
...ANSWER
Answered 2020-May-25 at 02:27Ideally, you wouldn't use the BehaviorSubject at all. From the Intro to Rx book:
The usage of subjects should largely remain in the realms of samples and testing. Subjects are a great way to get started with Rx. They reduce the learning curve for new developers, however they pose several concerns...
Better would be to do something like this in your viewDidLoad (or a function that is called from your viewDidLoad):
QUESTION
Binding a sectioned table with RxDataSources using a TableViewSectionedDataSource, requires sections which conform to SectionModelType.
This SectionModelType protocol has the following initializer as one of it's requirements:
...ANSWER
Answered 2020-Mar-19 at 23:02init(original:items:)
is a copy initializer. It takes an already existing instance of the struct and makes a new one that is identical except that it changes what's in the items
property.
So in a protocol declaration, init(original: Self, items: [Item])
means: "You hand me an already existing instance of whatever this type is that is conforming to me, the protocol, and we'll make a new instance that copies it while changing its items
."
And that is exactly what the example does. It's easier to see if you put it all together, like this:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install RxDataSources
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page