Giter Club home page Giter Club logo

rxasdatasources's Introduction

RxASDataSources

Platforms License Carthage compatible CocoaPods compatible Travis

RxDataSources for AsyncDisplayKit/Texture: ASTableNode & ASCollectionNode.

Features

  • O(N) Diff algorithm from RxDataSources/Differentiator
  • Shared RxDataSources's APIs so you must learn only once.
  • Supports ASTableNode and ASCollectionNode
  • Support nodeBlock
  • More complex Example app

Requirements

  • iOS 9.0+
  • Xcode 10.1+
  • RxSwift 5.0 & Texture 2.8

Installation

CocoaPods

To integrate RxASDataSources into your Xcode project using CocoaPods, specify it in your Podfile:

pod 'RxASDataSources'

Then, run the following command:

$ pod install

Carthage

To integrate RxASDataSources into your Xcode project using Carthage, specify it in your Cartfile:

github "RxSwiftCommunity/RxASDataSources"

Usage

Working with RxASDataSources will be very simple if you are familiar with RxDataSources:

typealias Section = SectionModel<String, Int>

let configureCell: ASTableSectionedDataSource<Section>.ConfigureCell = { (dataSource, tableNode, index, model) in
     let cell = ASTextCellNode()
     cell.text = model.info
     return cell
 }

 let animation = RowAnimation(insertAnimation: .automatic, reloadAnimation: .fade, deleteAnimation: .automatic)
 let dataSource = RxASTableSectionedReloadDataSource<Section>(animationConfiguration: animation, configureCell: configureCell)

 items
    .bind(to: tableNode.rx.items(dataSource: dataSource))
    .disposed(by: disposeBag)

For more advance usages, please follow RxDataSources and Example then simply replace your Views -> Nodes.

License

RxASDataSources is released under the MIT license. See LICENSE for details.

rxasdatasources's People

Contributors

dangthaison91 avatar foxware00 avatar fumito-ito avatar kemchenj avatar mongris avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

rxasdatasources's Issues

Pod specs seems to be pointing to old version of Texture (2.0)

Hello, thanks for a great tool.
I have Texture 3.0.0 installed on my machine. But installing RxASDataSources failed with the following error

[!] CocoaPods could not find compatible versions for pod "Texture":
  In snapshot (Podfile.lock):
    Texture (= 3.0.0)

  In Podfile:
    RxASDataSources was resolved to 0.2, which depends on
      Texture (~> 2.0)

    Texture

Is this a known issue or should I point to a specific branch for update version of RxASDataSources which depends on Texture 3+, as described on the repo version history?

Here is how my Podfile looks like

 pod 'Texture' # Texture 3.0.0 (Latest version)
 pod 'RxASDataSources' # Attempting to add RxASDataSources (This gives the error above on 'pod install command'

How to made datasource keep the old array of data if the new one is no different from the old one?

I'm developing an iOS app adhering to MVVM pattern and using RxASDataSources.

The application algorithm:

  1. The app fetches an array of data from my BE.
  2. Each element of the array is mapped to a viewmodel instance.
  3. The array is passed to RxASDataSources.
  4. Inside configureCell closure each viewmodel is bound to a node. For example, button.addTarget(viewmodel, action: #selector(didButtonTap), forControlEvents: .touchUpInside)

The issue with the datasource is if the new array of data is no different from the previous one (e.g a user refreshed the list), the datasource replaces the old array with the new one internally, but doesn't notify the nodes. If a node keeps reference to an element from data source after such refresh the node keeps the old element, but the datasource contains a new one.

timeout happens while reading xcworkspace

In my project, referencing RxASDataSources with Carthage, happens problems while carthage bootstrap with following messages.

xcodebuild timed out while trying to read RxASDataSources.xcworkspace 😭

Someone has same problems ? Is there a workaround?

  • carthage version: 0.29.0
  • xcodebuild -version: 9C40b
  • Are you using --no-build? No
  • Are you using --no-use-binaries? YES
  • Are you using --use-submodules? NO
  • Are you using --cache-builds? YES

Delegate methods not being called

I'm unable to get delegate methods to be called. I can't obviously set tableNode.dataSource = self and it seems all of the delegate methods fail to be called

I can't find an alternative for the following from RxDataSources

tableView.rx.setDelegate(self)
     .disposed(by: disposeBag)

however I am setting tableNode.delegate = self and still nothing
None of the following ever get triggered

func tableNode(_ tableNode: ASTableNode, willBeginBatchFetchWith context: ASBatchContext) {

func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? {

func shouldBatchFetch(for tableNode: ASTableNode) -> Bool {
... etc

RxSwift 5.+ Support

Currently, the builds support RxSwift 4.+ which is incompatible when using RxSwift 5.0.+ in the project. Making this unavailable to use with Swift 5 projects. Happy to open a PR, but will need some guidance getting the project working locally.

Move RxASDataSources to RxSwiftCommunity?

Hello,

I found out about RxASDataSources a few days ago.
I have also implemented a simpler version of it internally in my company,
because I didn’t know that someone else had developed one.

This is duplicated efford.

What do you think about moving this project to the RxSwiftCommunity?

Moving the project would make it easier for other developers to discover it and IMO it will offer
a better place for the community to contribute to it.

[Crash] ASDeallocQueue (15): Fatal error: Executing on background thread. Please use `MainScheduler.instance.schedule` to schedule work on main thread.

With following code:

class MyView: ASDisplayNode {
  let data = BehaviorRelay<Section>

  override func didLoad() {
        super.didLoad()

        data.asDriver()
            .map({ [$0] })
            .drive(collectionView.rx.items(dataSource: dataSource))
            .disposed(by: disposeBag)
    }
}

The app will be crash when dismissed view controller because ASDisplayNode was dealloc
in background thread.

Migrate to Swift 4.2 (and having problems building locally)

I'm trying to use this project in another swift 4.2 project (via Pods), and it has some syntax that needs to be updated to support swift 4.2

I'm trying to build locally and submit a P.R. but I am running into issues with missing xcconfig files which is preventing me from building locally.

image

Crash - nodeForItemAt (Precondition failed)

Hi you guys.

I have sometimes app crash for long time.

60712694-c8ad4500-9f41-11e9-9942-3fe6ebc86a82
Screen Shot 2019-10-08 at 5 06 19 PM

My Podfile.lock

  - RxASDataSources (0.3.3):
    - Differentiator (~> 3.0)
    - RxCocoa (~> 4.0)
    - RxSwift (~> 4.0)
    - Texture (~> 2.5)
  - Texture (2.7):
    - Texture/PINRemoteImage (= 2.7)
  - Texture/Core (2.7)
  - Texture/IGListKit (2.7):
    - IGListKit (~> 3.0)
    - Texture/Core
  - Texture/PINRemoteImage (2.7):
    - PINRemoteImage/iOS (= 3.0.0-beta.13)
    - PINRemoteImage/PINCache
    - Texture/Core

Do you guys have the same problem. It is very difficult to reproduce.

Function canEditRow isn't being called even when modelSelected is available.

rxTableViewDataSource.canEditRowAtIndexPath = { dataSource, indexPath in
            print("Can edit row")
            switch indexPath.section {
            case 0 : return false
            default : return true
        }
   }
        
rxTableViewDataSource.configureCell = { (dataSource, tableNode, indexPath, item) in
            let node = ASEngagementNode()
            if item.id == -1 {
                node.setPlaceholder(image: #imageLiteral(resourceName: "Announcement"))
            }
            node.conversation = item
            node.style.maxHeight = ASDimensionMake(105)
            return node
        }
tableView.rx.modelDeleted(RealmConversation.self)
    .subscribe()
    .disposed(by:bag)

Observable.combineLatest(Observable.array(from: conversations()),
                                 Observable.from(object: annoucement(), properties : ["read", "lastSenderMessage"]).catchError { error in
                                    print("Announcement update error : \(error)")
                                    return Observable.empty() })
            { ($0, $1) }
            .map { conversations, annoucement -> [ConversationSection] in
                return [ConversationSection(numbers: [annoucement], section: 0),
                        ConversationSection(numbers: conversations, section: 1)]
            }
            .bind(to: tableView.rx.items(dataSource: rxTableViewDataSource))
            .disposed(by:disposeBag)

I put debugger in and even at proxy level the canEditRow function still isn't being called.

Any ideas why this happened ?

performBatchUpdates method doesn't perform batch updates

RxSwiftCommunity/RxDataSources#271 issue relates to this library as well.
The same problem with RxASTableAnimatedDataSource. It performs separately each update from the batch.

for difference in differences {
dataSource.setSections(difference.finalSections)
tableNode.performBatchUpdates(difference, animated: self.animated, animationConfiguration: self.animationConfiguration)
}

public func performBatchUpdates<S>(_ changes: Changeset<S>, animated: Bool, animationConfiguration: RowAnimation) {
self.performBatch(animated: animated, updates: {
_performBatchUpdates(self, changes: changes, animationConfiguration: animationConfiguration)
}, completion: nil)
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.